forked from darwinia-network/crab-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (92 loc) · 3.34 KB
/
deploy-stg.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: Deploy staging
on:
push:
branches:
jobs:
deploy-develop:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Generate config data
run: |
jq -n \
--arg crab_smart_seed "${{ secrets.CRAB_SMART_SEED }}" \
'{
crab_smart_seed: $crab_smart_seed
}' | tee chain_data.json
jq -n \
--arg github_oauth_app_key "${{ secrets.X_GITHUB_OAUTH_APP_KEY }}" \
--arg github_oauth_app_secret "${{ secrets.X_GITHUB_OAUTH_APP_SECRET }}" \
'{
github_oauth_app_key: $github_oauth_app_key,
github_oauth_app_secret: $github_oauth_app_secret
}' | tee grant_data.json
jq -n \
--arg url "${{ secrets.REDIS_CONNECT_URL }}" \
'{
url: $url
}' | tee redis_data.json
- name: Render chain config
uses: jayamanikharyono/[email protected]
with:
datafile: chain_data.json
path: airdrop/api/config/chain.json
- name: Render grant config
uses: jayamanikharyono/[email protected]
with:
datafile: grant_data.json
path: airdrop/api/config/grant.json
- name: Render redis config
uses: jayamanikharyono/[email protected]
with:
datafile: redis_data.json
path: airdrop/api/config/redis.json
- name: Prepare Project Config
run: |
mv airdrop/api/config/chain.json airdrop/api/config/chain.safe.json
mv airdrop/api/config/grant.json airdrop/api/config/grant.safe.json
mv airdrop/api/config/redis.json airdrop/api/config/redis.safe.json
mv vercel.json build/
mv airdrop/* build/
- name: Deploy
id: deploy
run: |
REPO_NAME=${GITHUB_REPOSITORY#*/}
mv build $REPO_NAME
cd $REPO_NAME
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering link --confirm
vercel --token ${{ secrets.VERCEL_TOKEN }} --scope itering deploy | tee deploy.log
content=$(cat deploy.log)
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
echo ''
echo "::set-output name=VERCEL_OUTPUT::$content"
- name: Slack Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: darwinia-docs-edu
SLACK_COLOR: ${{ job.status }}
SLACK_ICON: https://avatars.githubusercontent.com/u/14985020?s=48&v=4
SLACK_MESSAGE: '${{ steps.deploy.outputs.VERCEL_OUTPUT }}'
SLACK_TITLE: Preview
SLACK_USERNAME: Vercel
SLACK_WEBHOOK: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}