-
Notifications
You must be signed in to change notification settings - Fork 12
134 lines (121 loc) · 5.21 KB
/
deploy_release.yaml
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
132
133
134
name: Deploy Release New
on:
push:
branches:
- master
- production
- staging
workflow_dispatch:
jobs:
bump_version:
name: Bump Version
runs-on: ubuntu-latest
outputs:
new_tag: ${{ steps.github_tag_action.outputs.new_tag }}
changelog: ${{ steps.github_tag_action.outputs.changelog }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: '0'
- name: Bump version and push tag
id: github_tag_action
uses: mathieudutour/[email protected]
with:
default_bump: minor
fetch_all_tags: true
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: production, staging
deploy:
name: Deploy Release
runs-on: ubuntu-latest
needs: bump_version
if: ${{ needs.bump_version.outputs.new_tag != null }}
steps:
- name: Pre-checks - Env is Dev
run: |
echo "ENV=development" >> $GITHUB_ENV
echo "SECRET_NAME=DEV_ENV" >> $GITHUB_ENV
- name: Pre-checks - Env is QA
if: ${{ endsWith(github.ref, '/staging') }}
run: |
echo "ENV=staging" >> $GITHUB_ENV
echo "SECRET_NAME=STAGING_ENV" >> $GITHUB_ENV
- name: Pre-checks - Env is PRODUCTION
if: ${{ endsWith(github.ref, '/production') }}
run: |
echo "ENV=production" >> $GITHUB_ENV
echo "SECRET_NAME=PRODUCTION_ENV" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Prepare .env and add secrets
run: |
env_name="${{ env.ENV }}"
dotenv_name="env/$env_name"
secret_name="${{ env.SECRET_NAME }}"
echo $env_name
cat env/shared
cat $dotenv_name
echo "setting environment from $dotenv_name"
cp env/shared .env
cat $dotenv_name >> .env
echo "setting environment from secrets file: $secret_name"
echo "${{ secrets.SHARED_ENV }}" >> .env
echo "${{ secrets[env.SECRET_NAME] }}" >> .env
echo "copying settings to GITHUB_ENV"
cat .env >> $GITHUB_ENV
- name: Load node v16
uses: actions/setup-node@v3
with:
node-version: '16.x'
cache: yarn
- name: Install dependencies
uses: borales/actions-yarn@v4
with:
cmd: install #yarn install
- name: Build app
run: yarn build
# Pinning
- name: Pin via web3 storage (Upload to web3 storage)
id: web3
uses: web3-storage/add-to-web3@v1
with:
web3_token: ${{ secrets.WEB3_STORAGE }}
path_to_add: './dist'
- name: Display pin address
run: |
echo published as ${{ steps.web3.outputs.url }}
echo cid ${{ steps.web3.outputs.cid }}
# DNS
- name: Update DNS with new IPFS hash
env:
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
RECORD_DOMAIN: ${{ env.CLOUDFLARE_DOMAIN }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
id: dnslink
uses: GoodDollar/[email protected]
with:
cid: ${{ steps.web3.outputs.cid }}
# GitHub release with links
- name: Create GitHub Release with tag ${{ needs.bump_version.outputs.new_tag }}
if: ${{ contains(github.ref, 'production') }}
id: create_release
uses: ncipollo/[email protected]
env:
DEPLOY_ADDR: '${{ env.SUBDOMAIN }}.${{ env.CLOUDFLARE_DOMAIN }}'
with:
tag: ${{ needs.bump_version.outputs.new_tag }}
name: ${{ needs.bump_version.outputs.new_tag }}
token: ${{ secrets.GITHUB_TOKEN }}
body: |
IPFS hash of the deployment:
- CID: `${{ steps.web3.outputs.cid }}`
The latest release is always accessible via our alias to the Cloudflare IPFS gateway at [${{ env.DEPLOY_ADDR }}](https://${{ env.DEPLOY_ADDR }}/).
IPFS gateways:
- ${{ steps.web3.outputs.url }}
- https://${{ steps.web3.outputs.cid }}.ipfs.dweb.link/
- https://${{ steps.web3.outputs.cid }}.ipfs.cf-ipfs.com/
- https://gateway.pinata.cloud/ipfs/${{ steps.web3.outputs.cid }}/
- https://cloudflare-ipfs.com/ipfs/${{ steps.web3.outputs.cid }}/
- https://ipfs.io/ipfs/${{ steps.web3.outputs.cid }}/
${{ needs.bump_version.outputs.changelog }}