forked from dfuse-io/dfuse-eosio
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (114 loc) · 4.49 KB
/
dockerimage.yml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Docker Image CI
run-name: Build image with dfuse-esoio:'${{ github.event.inputs.dfuse-eosio }}' and eosio:'${{ github.event.inputs.eosio }}'
on:
# Only allows triggering through the Github Workflow UI
workflow_dispatch:
inputs:
dfuse-eosio:
description: Tag from dfuse-eosio
required: true
type: string
eosio:
description: Tag from eosio
default: 'null'
required: false
type: string
overwrite-dfuse:
description: Overwrite existed dfuse Image.
default: false
type: boolean
ubuntu-version:
description: Specific Ubuntu version.
default: '22.04'
type: choice
options:
- '22.04'
- '18.04'
env:
DOCKER_IMAGE: europe-west1-docker.pkg.dev/ultra-registry/docker/dfuse-eosio
jobs:
build:
name: Build and Push image
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Set Dfuse Version
run: |
echo "DFUSE_TAG=${{ github.event.inputs.dfuse-eosio }}" >> $GITHUB_ENV
echo "UBUNTU_VERSION=${{ github.event.inputs.ubuntu-version }}" >> $GITHUB_ENV
- name: Set Nodeos Version
if: ${{ github.event.inputs.eosio != 'null' }}
run: |
echo "EOSIO_TAG=${{ github.event.inputs.eosio }}" >> $GITHUB_ENV
echo "DFUSE_NODEOS_TAG=${{ github.event.inputs.dfuse-eosio }}-nodeos${{ github.event.inputs.eosio }}" >> $GITHUB_ENV
# checkout based on dfuse tag
- name: Checkout dfuse-eosio
uses: actions/checkout@v3
with:
ref: "${{ env.DFUSE_TAG }}"
# check release commit
- name: Update Commit Hash
run: |
echo "RELEASE_COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
# Only download eosio if set
- name: Download EOSIO Debian package
if: ${{ github.event.inputs.eosio != 'null' }}
uses: Legion2/[email protected]
with:
repository: ultraio/eosio
tag: '${{ github.event.inputs.eosio }}'
path: .
file: eosio-${{ env.EOSIO_TAG }}.deb
token: '${{ secrets.DEVOPS_SECRET }}'
# gcloud authorization
# - id: 'auth'
# uses: 'google-github-actions/auth@v1'
# with:
# credentials_json: '${{ secrets.GCR_KEY }}'
#
- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
token_format: 'access_token'
workload_identity_provider: '${{ secrets.REG_WIF }}'
service_account: '[email protected]'
- name: Setup gcloud cli
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ultra-registry
- name: 'Login to GAR'
uses: docker/login-action@v2
with:
registry: europe-west1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
# # docker gcloud config
# - name: Docker config
# run: |
# gcloud auth configure-docker europe-west1-docker.pkg.dev -q
# Check if dfuse image is existed. Failed if not existed
- name: Check Dfuse Image
id: dfuse-check
continue-on-error: true
run: |
docker manifest inspect ${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_TAG }}
# Only build dfuse image if not existed or overwrite is set
- name: Build Dfuse Image Without Nodeos
if: ${{ (steps.dfuse-check.outcome == 'failure' || github.event.inputs.overwrite-dfuse == 'true') }}
run: |
docker build -f dfuse.Dockerfile . -t ${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_TAG }} \
--build-arg VERSION=${{ env.DFUSE_TAG }} \
--build-arg COMMIT=${{ env.RELEASE_COMMIT }} \
--build-arg UBUNTU_VERSION=${{ env.UBUNTU_VERSION }}
docker push ${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_TAG }}
# Only build dfuse with nodeos if eosio is set and dfuse image are exist
- name: Build Dfuse Image With Nodeos
if: ${{ github.event.inputs.eosio != 'null' }}
run: |
docker build -f nodeos.Dockerfile . -t ${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_NODEOS_TAG }} \
--build-arg DFUSE_IMAGE=${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_TAG }} \
--build-arg DEB_PKG=eosio-${{ env.EOSIO_TAG }}.deb
docker push ${{ env.DOCKER_IMAGE }}:${{ env.DFUSE_NODEOS_TAG }}