Skip to content

Merge pull request #39 from siemens/develop #19

Merge pull request #39 from siemens/develop

Merge pull request #39 from siemens/develop #19

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
jobs:
build-and-publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # 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@6a58db7e0d21ca03e6c44877909e80e45217eed2 # 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@2c0bd771b40637d97bf205cbccdd294a32112176 # 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@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # pin@v4
with:
context: .
file: ./deployments/gostwire/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
build-args: |
WSDISKPATHS=./ghostwire
REACT_APP_GIT_VERSION=${{ github.ref_name }}
build-contexts: |
webappsrc=./webui
${{ env.BUILDCONTEXTS }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Container virtual networks discovery service