Local devcontainers (take 2) #34
Workflow file for this run
This file contains hidden or 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
# Build and push the Docker image for GitHub Codespaces | |
# - Only pushes if push or release | |
# - Builds without push for PRs to check the Dockerfile | |
name: Build Docker [devcontainers] | |
on: | |
pull_request: # Build, don't push | |
paths: | |
- ".devcontainer/**" | |
- ".github/workflows/docker-devcontainer.yml" | |
push: { branches: [master] } # Build + push ('latest' tag) | |
release: { types: [published] } # Build + push (release tag) | |
workflow_dispatch: # Build + push (custom tag) | |
inputs: | |
tag_name: | |
description: "Docker image tag name" | |
type: string | |
required: true | |
jobs: | |
build_push: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Set tag variable | |
run: | | |
if [[ '${{ github.event_name }}' == 'release' ]]; then | |
echo "IMAGE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
elif [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then | |
echo "IMAGE_TAG=${{ inputs.tag_name }}" >> $GITHUB_ENV | |
else | |
echo "IMAGE_TAG=latest" >> $GITHUB_ENV | |
fi | |
- name: Check out the repo | |
uses: actions/checkout@v4 | |
- name: Set up QEMU for multi-architecture builds | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker buildx for multi-architecture builds | |
uses: docker/setup-buildx-action@v3 | |
with: | |
use: true | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Pre-build dev container image | |
uses: devcontainers/[email protected] | |
with: | |
configFile: .devcontainer/codespaces-dev/devcontainer.json | |
imageName: ghcr.io/${{ github.repository }} | |
imageTag: ${{ env.IMAGE_TAG }} | |
cacheFrom: ghcr.io/${{ github.repository }} | |
platform: linux/amd64,linux/arm64 | |
push: filter | |
eventFilterForPush: | | |
push | |
release | |
workflow_dispatch |