-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.08 KB
/
Copy pathdocker.yml
File metadata and controls
105 lines (89 loc) · 3.08 KB
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
100
101
102
103
104
105
---
name: Build docker image
on:
push:
tags:
- "v*"
- "*-v*"
branches:
- "develop"
- "feature/*"
workflow_dispatch:
env:
REGISTRY: gcr.io/eoscanada-shared-services
jobs:
build-vanilla:
runs-on: ubuntu-24.04
permissions:
contents: read
id-token: write
packages: write
strategy:
matrix:
go-version: [1.24.x]
outputs:
tags: ${{ steps.meta.outputs.tags }}
steps:
- uses: actions/checkout@v4
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
token_format: 'access_token'
workload_identity_provider: ${{ secrets.GCR_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GCR_SERVICE_ACCOUNT }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build with optimizations
run: go build -v -ldflags "-X main.version=${{ github.event.ref }} -X main.commit=${{ github.sha }} -X main.date=$(date -u +%Y-%m-%dT%H:%MZ) -s -w" -o ./evmx ./cmd/evmx
- name: Login to GCR
uses: docker/login-action@v3
with:
registry: gcr.io
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Branch and image name
id: extract_names
shell: bash
run: |
echo "##[set-output name=branch_name;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=image_name;]$(echo ${GITHUB_REPOSITORY#streamingfast/})"
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ steps.extract_names.outputs.image_name }}
tags: |
type=ref,event=tag
type=sha,prefix=,enable=${{ startsWith(github.ref, 'refs/heads/') }}
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/') }},value=${{ steps.extract_names.outputs.branch_name }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
slack-notifications:
needs: [build-vanilla]
runs-on: ubuntu-24.04
steps:
- name: Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/action-slack@2.0.2
with:
args: |
:done: *${{ github.repository }}* Success building docker images from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}```