Skip to content

Merge pull request #52 from thediveo/develop #22

Merge pull request #52 from thediveo/develop

Merge pull request #52 from thediveo/develop #22

name: Build and release multi-arch container images
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-*'
env:
PLATFORMS: linux/amd64,linux/arm64
BUILDCONTEXTS: "" # ugly band-aid as per https://github.com/github/vscode-github-actions/issues/47#issuecomment-1488592302
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # pin@v3
- name: Get all git tags
run: |
git fetch --prune --unshallow --tags --force
- name: Burn in version information
run: go generate .
- name: Set up QEMU
uses: docker/setup-qemu-action@2b82ce82d56a2a04d2637cd93a637ae1b359c0a7 # pin@v2
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up Docker buildx
uses: docker/setup-buildx-action@885d1462b80bc1c1c7f0b00334ad271f09369c55 # pin@v2
- name: Log into the container registry
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # pin@v2
if: github.ref_type == 'tag'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 # pin@v4
id: metadata # later referenced as "steps.metadata."
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value={{sha}},enable=${{ github.ref_type != 'tag' }}
- name: Prepare (fake) Go workspace and build contexts
shell: bash
run: |
mkdir .emptyctx
NUMCONTEXTS=9
buildcontexts=""
for ((ctxno=1;ctxno<=NUMCONTEXTS;ctxno++)); do
buildcontexts+=$'\n'"bctx${ctxno}=.emptyctx"
done
EOF="**ENDOFTHEINTERNET**"
echo "BUILDCONTEXTS<<$EOF" >> $GITHUB_ENV
echo "$buildcontexts" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@0a97817b6ade9f46837855d676c4cca3a2471fc9 # pin@v4
with:
context: .
file: ./deployments/lxkns/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
WSDISKPATHS=./lxkns
GIT_VERSION=${{ github.ref_name }}
build-contexts: |
webappsrc=./web/lxkns
${{ env.BUILDCONTEXTS }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Linux
kernel namespaces discovery