-
Notifications
You must be signed in to change notification settings - Fork 46
96 lines (83 loc) · 3.23 KB
/
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
name: Docs deploy
run-name: Deploy of ${{ github.ref_name }} to ${{github.event.inputs.environment}}
on:
workflow_dispatch:
inputs:
environment:
type: choice
description: Target
required: true
options:
- STAGE # www-stage.ankr.com/docs/
- BS1 # bs-1-stage.dccn.ankr.com/docs/
- BS2 # bs-2-stage.dccn.ankr.com/docs/
- BS3 # bs-3-stage.dccn.ankr.com/docs/
- BS4 # bs-4-stage.dccn.ankr.com/docs/
- PROD # www.ankr.com/docs/
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: nelonoel/[email protected]
- name: Prevent wrong version releasing
if: ${{ github.event.inputs.environment == 'PROD' && github.ref != 'refs/heads/main' }}
run: |
echo "Production deployment is possible only from the main branch"
exit 1
- name: Get deployment information
run: |
echo "Branch: ${BRANCH_NAME}"
echo "Domain: ${{github.event.inputs.environment}}"
- name: Setup Node.js environment
uses: actions/[email protected]
with:
node-version: '18.19.0'
- name: Build
working-directory: .
run: |
yarn install
yarn build
- uses: actions/checkout@v3
with:
ref: main
repository: Ankr-network/staking-frontend
token: ${{ secrets.ACCESS_TOKEN }}
path: staking-frontend
- name: Install dependencies and build doc sdk
run: |
yarn install --cwd staking-frontend/packages/staking-sdk
cd staking-frontend/packages/staking-sdk
yarn docs
- name: Copy build
run: |
cd out/staking-for-developers/sdk/
mkdir liquid-staking
cd liquid-staking
mkdir reference
cd ../../../../
mv staking-frontend/packages/staking-sdk/docs/* out/staking-for-developers/sdk/liquid-staking/reference
- name: Set AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy files to the production website with the AWS CLI
working-directory: .
env:
DOMAIN: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DOMAIN')] }}
DISTRIBUTION_ID: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DISTRIBUTION_ID')] }}
run: |
aws s3 sync --delete ./out s3://$DOMAIN/docs/ --acl public-read --cache-control "public,max-age=600,s-maxage=3600"
aws configure set preview.cloudfront true
echo "Invalidating CDN network"
INVALIDATION_ID=`aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' | jq -r '.Invalidation.Id'`
echo "Invalidation ID is $INVALIDATION_ID"
echo "CDN Invalidation request is sent."
- name: Set redirections
working-directory: .
env:
DOMAIN: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DOMAIN')] }}
run: |
node redirects.js