chore: Update GitHub actions to run on custom runner and push to Google Artifact Registry

This commit updates the GitHub workflows to push Docker images to Google Artifact Registry.
Additionally, it refines event conditions, separates build ID generation for normal pushes and tag pushes, and introduces tagging workflow for '*-sgx-*' tags.

Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
This commit is contained in:
Harald Hoyer 2024-06-28 10:38:24 +02:00
parent 8329eb8b96
commit 695355d095
Signed by: harald
GPG key ID: F519A1143B3FBE32

View file

@ -5,6 +5,7 @@ on:
branches: [ "main" ] branches: [ "main" ]
push: push:
branches: [ "main" ] branches: [ "main" ]
tags: [ "*-sgx-*" ]
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
@ -102,21 +103,38 @@ jobs:
docker push matterlabsrobot/"${{ steps.build.outputs.IMAGE_TAG }}" docker push matterlabsrobot/"${{ steps.build.outputs.IMAGE_TAG }}"
- name: Tag container as latest - name: Tag container as latest
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} if: ${{ github.event_name == 'push' }}
run: | run: |
docker tag "${{ steps.build.outputs.IMAGE_TAG }}" matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:latest" docker tag "${{ steps.build.outputs.IMAGE_TAG }}" matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:latest"
docker push matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:latest" docker push matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:latest"
- name: Generate build ID for Flux Image Automation - name: Generate build ID for Flux Image Automation
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} id: flux
id: buildid if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags') }}
run: | run: |
sha=$(git rev-parse --short HEAD) sha=$(git rev-parse --short HEAD)
ts=$(date +%s%N | cut -b1-13) ts=$(date +%s%N | cut -b1-13)
echo "BUILD_ID=${sha}-${ts}" >> "$GITHUB_OUTPUT" echo "BUILD_ID=${sha}-${ts}" >> "$GITHUB_OUTPUT"
- name: Push Docker image to matterlabs-infra - name: Generate build ID for Flux Image Automation
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} id: tag
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
run: | run: |
docker tag "${{ steps.build.outputs.IMAGE_TAG }}" matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.buildid.outputs.BUILD_ID }}" echo "BUILD_ID=${GITHUB_REF#refs/*/}" >> "$GITHUB_OUTPUT"
docker push matterlabsrobot/"${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.buildid.outputs.BUILD_ID }}"
- name: Auth to google artifact registry
if: ${{ github.event_name == 'push' }}
run: |
gcloud auth configure-docker us-docker.pkg.dev -q
- name: Push Docker image to matterlabs-infra
if: ${{ github.event_name == 'push' && !startsWith(github.ref, 'refs/tags') }}
run: |
docker tag "${{ steps.build.outputs.IMAGE_TAG }}" "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.flux.outputs.BUILD_ID }}"
docker push "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.flux.outputs.BUILD_ID }}"
- name: Push Docker image to matterlabs-infra
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
run: |
docker tag "${{ steps.build.outputs.IMAGE_TAG }}" "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.tag.outputs.BUILD_ID }}"
docker push "us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/${{ steps.build.outputs.IMAGE_NAME }}:${{ steps.tag.outputs.BUILD_ID }}"