A revised docker build procedure and infrastructure (#79) #76
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: Publish Docker image | |
on: | |
push: | |
branches: | |
- "main" | |
- "develop" | |
tags: | |
- "v*" | |
env: | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
platform: | |
- linux/amd64 | |
permissions: | |
id-token: write | |
contents: write | |
packages: write | |
steps: | |
- name: Prepare | |
run: | | |
platform=${{ matrix.platform }} | |
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Docker Setup Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: "Authenticate to Google Cloud" | |
id: google-auth | |
uses: "google-github-actions/auth@v1" | |
with: | |
token_format: "access_token" | |
workload_identity_provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}" | |
service_account: "${{ secrets.GCP_PRD_GITHUB_SA_DOCKER_REGISTRY }}" | |
create_credentials_file: true | |
- name: Login to the registry - production | |
uses: docker/login-action@v2 | |
with: | |
registry: asia-docker.pkg.dev | |
username: oauth2accesstoken | |
password: "${{ steps.google-auth.outputs.access_token }}" | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker Login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Metadata action | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
zilliqa/otterscan | |
asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-public/otterscan | |
tags: | | |
type=ref,enable=false,priority=600,prefix=pr-,suffix=,event=pr | |
type=ref,event=branch | |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | |
type=semver,pattern={{raw}} | |
- name: "Build and push ${{ matrix.application }}" | |
env: | |
ENVIRONMENT: stg | |
IMAGE_TAG: ${{ steps.set-tag.outputs.tags }} | |
run: | | |
cd ${{ matrix.path }} | |
make image/build-and-push | |