-
Notifications
You must be signed in to change notification settings - Fork 11
130 lines (113 loc) · 4.35 KB
/
Copy pathdeploy.yml
File metadata and controls
130 lines (113 loc) · 4.35 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
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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build and Publish Docker image
on:
push:
branches:
- 'master'
- 'ibtida'
tags:
- 'v*'
pull_request:
branches:
- 'master'
- 'ibtida'
jobs:
build-docker-images:
runs-on: ubuntu-20.04
outputs:
image-version: ${{ steps.meta.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Get changes on Dockerfile
id: changed-dockerfile
uses: tj-actions/changed-files@v1.0.0
with:
files: Dockerfile*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' || github.event_name != 'pull_request' }}
- name: Login to DockerHub
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' || github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER_NAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: build-meta
uses: docker/metadata-action@v3
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' }}
with:
images: anmolnetwork/anmol-node-build
tags: |
type=ref,event=branch
type=sha,prefix=,latest=true
labels: |
org.opencontainers.image.vendor=Anmol Network
org.opencontainers.image.url=https://anmol.network
- name: Build and push builder image
uses: docker/build-push-action@v2
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' }}
with:
file: ./Dockerfile.build
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.build-meta.outputs.tags }}
labels: ${{ steps.build-meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' || github.event_name != 'pull_request' }}
with:
images: anmolnetwork/anmol-node
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
labels: |
org.opencontainers.image.vendor=Anmol Network
org.opencontainers.image.url=https://anmol.network
- name: Build and push production image
uses: docker/build-push-action@v2
if: ${{ steps.changed-dockerfile.outputs.any_changed == 'true' || github.event_name != 'pull_request' }}
with:
build-args: |
SCCACHE_BUCKET=${{ secrets.SCCACHE_BUCKET }}
AWS_ACCESS_KEY_ID=${{ secrets.SCCACHE_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY=${{ secrets.SCCACHE_AWS_SECRET_ACCESS_KEY }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-images:
runs-on: ubuntu-20.04
if: ${{ github.event_name != 'pull_request' }}
needs:
- build-docker-images
steps:
- name: Update image version of the network spec
uses: "OnFinality-io/action-onf-release@v1"
with:
onf-access-key: ${{ secrets.ONF_ACCESS_KEY }}
onf-secret-key: ${{ secrets.ONF_SECRET_KEY }}
onf-workspace-id: ${{ secrets.ONF_WORKSPACE_ID }}
onf-network-key: ${{ secrets.ONF_NETWORK_KEY }}
onf-sub-command: image
onf-action: add
image-version: ${{ needs.build-docker-images.outputs.image-version }}
- name: Perform a rolling update to all nodes
uses: "OnFinality-io/action-onf-release@v1"
with:
onf-access-key: ${{ secrets.ONF_ACCESS_KEY }}
onf-secret-key: ${{ secrets.ONF_SECRET_KEY }}
onf-workspace-id: ${{ secrets.ONF_WORKSPACE_ID }}
onf-network-key: ${{ secrets.ONF_NETWORK_KEY }}
onf-sub-command: node
onf-action: upgrade
image-version: ${{ needs.build-docker-images.outputs.image-version }}
percent: 30