Skip to content

Build devcontainer image #159

Build devcontainer image

Build devcontainer image #159

Workflow file for this run

name: Build devcontainer image
on:
push:
branches: [master]
paths:
- ".devcontainer/**"
- ".dockerignore"
- "vcpkg.json"
- "*/*.csproj"
- ".github/workflows/devcontainer.yml"
pull_request:
branches: [master]
paths:
- ".devcontainer/**"
- ".dockerignore"
- "vcpkg.json"
- "*/*.csproj"
- ".github/workflows/devcontainer.yml"
# Run once a week
schedule:
- cron: "34 2 * * 2"
permissions:
contents: read
packages: write
jobs:
build:
name: Build devcontainer image
strategy:
fail-fast: false
matrix:
runner: [ubuntu-latest, ubuntu-22.04-arm64]
runs-on: ${{ matrix.runner }}
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Compute image info
id: image
run: |
echo "name=ghcr.io/$(echo ${{ github.repository }} | tr A-Z a-z)/devcontainer" >> "$GITHUB_OUTPUT"
echo "push=${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'schedule' }}" >> "$GITHUB_OUTPUT"
- name: Compute image labels
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.image.outputs.name }}
tags: latest
labels: |
org.opencontainers.image.title=ParquetSharp devcontainer
org.opencontainers.image.description=devcontainer for ParquetSharp
- if: fromJson(steps.image.outputs.push)
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image${{ fromJson(steps.image.outputs.push) && ' and push it by digest' || ''}}
id: build
uses: docker/build-push-action@v6
with:
file: .devcontainer/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ steps.image.outputs.name }},push-by-digest=true,name-canonical=true,push=${{ steps.image.outputs.push }}
cache-from: type=gha,scope=${{ github.ref }}-${{ matrix.runner }}
cache-to: type=gha,scope=${{ github.ref }}-${{ matrix.runner }},mode=max
- if: fromJson(steps.image.outputs.push)
name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- if: fromJson(steps.image.outputs.push)
name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.runner }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
outputs:
image_name: ${{ steps.image.outputs.name }}
image_push: ${{ steps.image.outputs.push }}
merge:
name: Merge platforms
if: fromJson(needs.build.outputs.image_push)
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-*
path: /tmp/digests
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t ${{ needs.build.outputs.image_name }}:latest \
$(printf '${{ needs.build.outputs.image_name }}@sha256:%s ' *)
- name: Inspect image
run: docker buildx imagetools inspect ${{ needs.build.outputs.image_name }}:latest