Skip to content

chore(deps): update docker/setup-buildx-action action to v3.7.0 #140

chore(deps): update docker/setup-buildx-action action to v3.7.0

chore(deps): update docker/setup-buildx-action action to v3.7.0 #140

Workflow file for this run

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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- 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@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
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@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
if: steps.changes.outputs.needs_build == 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8026d2bc3645ea78b0d2544766a1225eb5691f89 # v3.7.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' }}