chore(deps): update github/codeql-action action to v3.28.1 (#158) #167
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
prepare: | |
name: Prepare list of images to build | |
runs-on: ubuntu-latest | |
outputs: | |
images: ${{ steps.set-matrix.outputs.images }} | |
steps: | |
- name: Check out the source code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set matrix | |
id: set-matrix | |
run: echo images="$(jq '."x-build"' images/src/*/.devcontainer.json | jq --slurp -c .)" >> "${GITHUB_OUTPUT}" | |
publish-images: | |
needs: prepare | |
name: 'Publish ${{ matrix.image.name }}' | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
fail-fast: false | |
matrix: | |
image: ${{ fromJson(needs.prepare.outputs.images) }} | |
steps: | |
- name: Check out the source code | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Check changed files | |
id: changes | |
run: | | |
if [ "${{ github.event_name }}" = "push" ]; then | |
base="${{ github.event.before }}" | |
head="${{ github.event.after }}" | |
image="images/src/${{ matrix.image.image-name }}" | |
changes="$(git diff --name-only "${base}" "${head}" -- "${image}" | grep -Fv "${image}/README.md" || true)" | |
if [ -n "${changes}" ]; then | |
echo needs_build=true >> "${GITHUB_OUTPUT}" | |
else | |
echo needs_build=false >> "${GITHUB_OUTPUT}" | |
fi | |
else | |
echo needs_build=true >> "${GITHUB_OUTPUT}" | |
fi | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0 | |
if: steps.changes.outputs.needs_build == 'true' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 | |
if: steps.changes.outputs.needs_build == 'true' | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
if: steps.changes.outputs.needs_build == 'true' | |
with: | |
registry: https://ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set versions | |
if: steps.changes.outputs.needs_build == 'true' | |
id: set-versions | |
run: | | |
echo major="$(echo "${{ matrix.image.image-version }}" | cut -d. -f1)" >> "${GITHUB_OUTPUT}" | |
echo minor="$(echo "${{ matrix.image.image-version }}" | cut -d. -f2)" >> "${GITHUB_OUTPUT}" | |
echo patch="$(echo "${{ matrix.image.image-version }}" | cut -d. -f3)" >> "${GITHUB_OUTPUT}" | |
- name: Check if image already exists | |
if: steps.changes.outputs.needs_build == 'true' | |
id: exists | |
run: | | |
if docker buildx imagetools inspect "ghcr.io/${{ github.repository }}/${{ matrix.image.image-name }}:${{ steps.set-versions.outputs.major }}.${{ steps.set-versions.outputs.minor }}.${{ steps.set-versions.outputs.patch }}" > /dev/null 2>&1; then | |
echo exists=true >> "${GITHUB_OUTPUT}" | |
else | |
echo exists=false >> "${GITHUB_OUTPUT}" | |
fi | |
- name: Install @devcontainers/cli | |
run: npm install -g @devcontainers/cli | |
if: ${{ steps.changes.outputs.needs_build == 'true' && steps.exists.outputs.exists != 'true' }} | |
- name: Build image | |
run: | | |
devcontainer build \ | |
--workspace-folder "images/src/${{ matrix.image.image-name }}" \ | |
--platform linux/amd64,linux/arm64 \ | |
--image-name=ghcr.io/${{ github.repository }}/${{ matrix.image.image-name }}:${{ steps.set-versions.outputs.major }}.${{ steps.set-versions.outputs.minor }}.${{ steps.set-versions.outputs.patch }} \ | |
--image-name=ghcr.io/${{ github.repository }}/${{ matrix.image.image-name }}:${{ steps.set-versions.outputs.major }}.${{ steps.set-versions.outputs.minor }} \ | |
--image-name=ghcr.io/${{ github.repository }}/${{ matrix.image.image-name }}:${{ steps.set-versions.outputs.major }} \ | |
--image-name=ghcr.io/${{ github.repository }}/${{ matrix.image.image-name }}:latest \ | |
--push | |
if: ${{ steps.changes.outputs.needs_build == 'true' && steps.exists.outputs.exists != 'true' }} |