ci: update release process with release-please #96
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 and push Docker image | |
on: | |
workflow_call: | |
inputs: | |
tag: | |
type: string | |
description: 'The tag to use for the Docker image' | |
required: true | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-push-image: | |
name: Build and Push Docker Image | |
runs-on: matterlabs-ci-runner-high-performance | |
env: | |
DOCKERHUB_IMAGE: us-docker.pkg.dev/matterlabs-infra/matterlabs-docker/anvil-zksync | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Determine Base Tag | |
id: set_tag | |
shell: 'bash -ex {0}' | |
run: | | |
[ ! -z "${{ inputs.tag }}" ] && BASE_TAG="${{ inputs.tag }}" \ | |
|| BASE_TAG="$(git rev-parse --short HEAD)-$(date +%s%N | cut -b1-13)" | |
echo "base_tag=${BASE_TAG}" >> "${GITHUB_OUTPUT}" | |
- name: Login to GAR | |
run: gcloud auth configure-docker us-docker.pkg.dev -q | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v6 | |
id: push | |
with: | |
context: . | |
push: ${{ github.event_name != 'pull_request' }} | |
platforms: 'linux/amd64,linux/arm64' | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: | | |
ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.base_tag }} | |
${{ env.DOCKERHUB_IMAGE }}:${{ steps.set_tag.outputs.base_tag }} | |
- name: Generate docker image attestation | |
if: ${{ inputs.tag != '' }} | |
uses: actions/attest-build-provenance@v1 | |
with: | |
subject-name: ghcr.io/${{ github.repository }} | |
subject-digest: ${{ steps.push.outputs.digest }} | |
push-to-registry: true | |
- name: Print image digest to summary | |
run: | | |
echo "Image tags: ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.base_tag }}" >> "${GITHUB_STEP_SUMMARY}" | |
echo "Image tags: ${{ env.DOCKERHUB_IMAGE }}:${{ steps.set_tag.outputs.base_tag }}" >> "${GITHUB_STEP_SUMMARY}" |