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 blockscout image | |
on: | |
push: | |
branches: | |
- "main" | |
- "master" | |
- "production" | |
- "dev" | |
# Trigger without any parameters a proactive rebuild | |
workflow_dispatch: {} | |
workflow_call: | |
env: | |
IMAGE_NAME: gcr.io/blockscout-backend-test-optimism | |
jobs: | |
container: | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/reference/authentication-in-a-workflow | |
permissions: | |
id-token: write | |
packages: write | |
contents: read | |
timeout-minutes: 60 | |
steps: | |
- name: Checkout repository | |
id: checkout | |
uses: actions/checkout@v3 | |
- name: Install Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
id: buildx | |
with: | |
install: true | |
- name: set-env | |
if: ${{ github.ref == 'refs/heads/master' }} | |
run: | | |
echo "REGISTRY=us-docker.pkg.dev/exfac-staging" >> $GITHUB_ENV | |
- id: "auth" | |
name: "Authenticate to Google Cloud" | |
uses: "google-github-actions/auth@v0" | |
with: | |
credentials_json: ${{ github.ref == 'refs/heads/production' && secrets.DEPLOYER_SERVICE_ACCOUNT_KEY || github.ref == 'refs/heads/main' && secrets.STAGING_DEPLOYER_SERVICE_ACCOUNT_KEY || github.ref == 'refs/heads/dev' && secrets.DEV_DEPLOYER_SERVICE_ACCOUNT_KEY }} | |
- name: Authenticate docker | |
run: | | |
gcloud auth configure-docker --quiet us-docker.pkg.dev | |
# Extract metadata (tags, labels) for Docker | |
# https://github.com/docker/metadata-action | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
# If the job is triggered via workflow dispatch and on a master branch, tag branch and latest | |
# Otherwise, just tag as the branch name | |
- name: Finalize Docker Metadata | |
id: docker_tagging | |
run: | | |
echo "manual trigger from master/master branch, assigning latest tag" | |
echo "::set-output name=docker_tags::${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_REF##*/},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" | |
# Log docker metadata to explicitly know what is being pushed | |
- name: Inspect Docker Metadata | |
run: | | |
echo "TAGS -> ${{ steps.docker_tagging.outputs.docker_tags }}" | |
echo "LABELS -> ${{ steps.meta.outputs.labels }}" | |
# Build and push Docker image | |
# https://github.com/docker/build-push-action | |
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
file: ./docker/Dockerfile | |
labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.docker_tagging.outputs.docker_tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
build-args: | | |
BUILDTIME=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }} | |
VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }} | |
REVISION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }} | |
CACHE_EXCHANGE_RATES_PERIOD= | |
DISABLE_READ_API=false | |
API_PATH=/ | |
NETWORK_PATH=/ | |
DISABLE_WEBAPP=false | |
DISABLE_WRITE_API=false | |
CACHE_ENABLE_TOTAL_GAS_USAGE_COUNTER= | |
WOBSERVER_ENABLED=false | |
ADMIN_PANEL_ENABLED= | |
CACHE_ADDRESS_WITH_BALANCES_UPDATE_INTERVAL= | |
SOCKET_ROOT= |