build-devcontainer #66
Workflow file for this run
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-devcontainer | |
on: | |
workflow_call: | |
inputs: | |
CLAB_VERSION: | |
description: "Containerlab version" | |
required: true | |
type: string | |
workflow_dispatch: | |
inputs: | |
CLAB_VERSION: | |
description: "Containerlab version" | |
default: "0.59.0" | |
required: false | |
type: string | |
TAG: | |
description: "Additional container image tag" | |
required: false | |
type: string | |
# trigger on published release event | |
# to created the dev container when the packages are published | |
release: | |
types: | |
- published | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
devcontainer: | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
variant: | |
- "dind" | |
- "dind-slim" | |
- "dood" | |
- "dood-slim" | |
include: | |
- variant: dind | |
devContFile: .devcontainer/docker-in-docker/devcontainer.json | |
image-suffix: "-dind" | |
- variant: dind-slim | |
devContFile: .devcontainer/docker-in-docker_slim/devcontainer.json | |
image-suffix: "-dind-slim" | |
- variant: dood | |
devContFile: .devcontainer/docker-outside-of-docker/devcontainer.json | |
image-suffix: "-dood" | |
- variant: dood-slim | |
devContFile: .devcontainer/docker-outside-of-docker_slim/devcontainer.json | |
image-suffix: "-dood-slim" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry ${{ env.REGISTRY }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# https://github.com/devcontainers/ci/issues/268#issuecomment-1976014578 | |
- name: remove existing skopeo | |
run: | | |
sudo rm -rf $(which skopeo) | |
- name: Update skopeo | |
run: | | |
REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04" | |
sudo sh -c "echo 'deb ${REPO_URL}/ /' > /etc/apt/sources.list.d/skopeo.list" | |
curl -fsSL ${REPO_URL}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/skopeo.gpg > /dev/null | |
sudo apt update | |
sudo apt install skopeo | |
skopeo --version | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ github.repository }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=ref,event=branch | |
type=ref,event=pr | |
# git short commit | |
type=sha | |
# manually set tag | |
type=raw,value=${{ inputs.tag }} | |
- name: Extract tags | |
id: extract-tags | |
run: | | |
TAGS=$(echo '${{ steps.meta.outputs.tags }}' | awk -F: '{print $2}' | paste -sd "," -) | |
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Build dev container image | |
uses: devcontainers/[email protected] | |
env: | |
CLAB_VERSION: ${{ inputs.clab_version }} | |
with: | |
imageName: ghcr.io/${{ github.repository }}/devcontainer${{ matrix.image-suffix }} | |
imageTag: ${{ steps.extract-tags.outputs.tags }} | |
push: always | |
platform: linux/amd64,linux/arm64 | |
configFile: ${{ matrix.devContFile }} |