Skip to content

Build and push images to GHCR on tag #24

Build and push images to GHCR on tag

Build and push images to GHCR on tag #24

Workflow file for this run

name: build-and-push-images
on:
push:
tags:
- "v*.*.*"
pull_request:
permissions:
contents: read
packages: write
id-token: write
jobs:
build:
env:
REGISTRY: ghcr.io
strategy:
matrix:
workload:
- path: aws/consumer
repo: aws_consumer
- path: aws/analysis
repo: aws_analysis
- path: ping-pong/client
repo: ping_pong_client
- path: ping-pong/server
repo: ping_pong_server
- path: ping-pong-mesh/client
repo: ping_pong_mesh_client
- path: ping-pong-mesh/server
repo: ping_pong_mesh_server
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: workloads/${{matrix.workload.path}}/go.mod
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v6
with:
args: --timeout=5m
working-directory: workloads/${{matrix.workload.path}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set image name
run: echo "IMAGE_NAME=${{github.repository_owner}}/${{matrix.workload.repo}}" >> $GITHUB_ENV
- name: Build and push
id: push
uses: docker/build-push-action@v4
with:
context: workloads/${{ matrix.workload.path }}
# push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') }}
push: true
platforms: linux/amd64, linux/arm64
tags: |
${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest
${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && format('{0}/{1}:{2}', env.REGISTRY, env.IMAGE_NAME, github.ref_name) || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Generate artifact attestation
# uses: actions/attest-build-provenance@v2
# with:
# subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true