-
Notifications
You must be signed in to change notification settings - Fork 8
106 lines (87 loc) · 3.36 KB
/
prod_deploy.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
name: Manual Deployment to Prod
on:
workflow_dispatch:
inputs:
version:
description: "Release version to deploy"
required: true
type: string
network:
description: "Network for Subgraph deployment - (Gnosis Chain or Ethereum)"
required: true
options:
- Ethereum
- Gnosis Chain
- ALL
type: choice
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Deployment
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Check version tag exists
id: release_tag
run: |
TAG_EXISTS=$(git tag -l "${{ inputs.version }}")
if [ -z "$TAG_EXISTS" ]; then
echo "Version ${{ inputs.version }} does not exist."
exit 1
else
echo "tag=$TAG_EXISTS" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
- name: Install graph-cli & dependencies
run: |
yarn run clean
yarn global add @graphprotocol/graph-cli
yarn install
- name: Build Subgraph for ETH mainnet
if: ${{ inputs.network == 'Ethereum' }}
run: yarn codegen && yarn build
- name: Build Subgraph for Gnosis Chain
if: ${{ inputs.network == 'Gnosis Chain' }}
run: yarn codegen && yarn build:gc
- name: Build Subgraph for both Netwroks
if: ${{ inputs.network == 'ALL' }}
run: yarn doall
- name: Authenticate to Subgraph Studio
run: graph auth --studio ${{ secrets.DEPLOY_KEY }}
# Script to deploy to production environment
- name: Generate Random ID for buildcode
id: random_id
run: |
echo "random_id=$(openssl rand -hex 4)" >> $GITHUB_OUTPUT
- name: Deploy Subgraph for ETH mainnet
if: ${{ inputs.network == 'Ethereum' }}
run: yarn deploy -l "${{ steps.release_tag.outputs.tag }}-${{ steps.random_id.outputs.random_id }}"
- name: Deploy Subgraph for Gnosis Chain
if: ${{ inputs.network == 'Gnosis Chain' }}
run: yarn deploy:gc -l "${{ steps.release_tag.outputs.tag }}-${{ steps.random_id.outputs.random_id }}"
- name: Deploy Subgraph for both Netwroks
if: ${{ inputs.network == 'ALL' }}
run: yarn deploy -l "${{ steps.release_tag.outputs.tag }}-${{ steps.random_id.outputs.random_id }}" && yarn deploy:gc -l "${{ steps.release_tag.outputs.tag }}-${{ steps.random_id.outputs.random_id }}"
notify:
uses: ./.github/workflows/slack_release_notification.yml
if: ${{ always() }}
needs: deploy
secrets:
RELEASES_SLACK_WEBHOOK_URL: ${{ secrets.RELEASES_SLACK_WEBHOOK_URL }}
with:
environment: Production
service: GC Voting Snapshot SubGraph
success: ${{ contains(join(needs.*.result, ','), 'success') }}
message: "deploy service `GC Voting Snapshot SubGraph` version `${{ inputs.version }}`. Triggered by `${{ github.actor }}`."