forked from blockscout/blockscout
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (89 loc) · 3.59 KB
/
build.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: build blockscout image
on:
push:
branches:
- "master"
- "production"
- "dev"
# Trigger without any parameters a proactive rebuild
workflow_dispatch: {}
workflow_call:
env:
IMAGE_NAME: gcr.io/blockscout-backend-test
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/master' && 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=