Skip to content

[WIP] Devcontainer setup #72

[WIP] Devcontainer setup

[WIP] Devcontainer setup #72

name: Build Dev Container Base Image
on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master
workflow_dispatch: # Manually triggered
env:
CONTAINER_REGISTRY: ghcr.io
IMAGE_NAME: access-system-dev
BRANCH_NAME: ${{ github.head_ref || github.ref }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🧰 Get branch name
run: | # Get the branch name from the ref and replace non-alphanumeric characters with hyphens
BRANCH=$(echo "${BRANCH_NAME#refs/heads/}" | sed -e 's/[^a-zA-Z0-9]/-/g')
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- name: 🏷️ Generate Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.CONTAINER_REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,priority=610
type=ref,event=pr
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern=v{{major}}
type=sha,format=long
type=raw,value=latest,enable={{is_default_branch}}
type=raw,value=${{ env.BRANCH_NAME }},priority=10
annotations: |
runnumber=${{ github.run_id }}
sha=${{ github.sha }}
ref=${{ github.ref }}
- name: 🔐 Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 🚀 Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: .devcontainer/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max