-
Notifications
You must be signed in to change notification settings - Fork 8
129 lines (117 loc) · 5.01 KB
/
deploy.branch.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Deploy temporary instance
on:
push:
branches:
- feat/**
- feature/**
- fix/**
- hotfix/**
- docs/**
- style/**
- refactor/**
- perf/**
- test/**
- build/**
- ci/**
- chore/**
- revert/**
env:
AWS_ACCESS_KEY_ID: ${{ secrets.HYPHA_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HYPHA_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-west-1
NODE_ENV: development
BRANCH_PR_NUMBER: ${{ github.event.number }}
APP_NAME: 'Hypha DHO'
NETWORK_CHAIN_ID: ${{ vars.NETWORK_CHAIN_ID }}
DAO_CONTRACT: ${{ vars.DAO_CONTRACT }}
HYPHA_CONTRACT: ${{ vars.HYPHA_CONTRACT }}
SUPPLY_CONTRACT: ${{ vars.SUPPLY_CONTRACT }}
MULTISIG_CONTRACT: ${{ vars.MULTISIG_CONTRACT }}
KV_CONTRACT: ${{ vars.KV_CONTRACT }}
PPP_ENV: ${{ vars.PPP_ENV }}
ACCOUNT_API_URL: ${{ vars.ACCOUNT_API_URL }}
ACCOUNT_API_KEY: ${{ secrets.ACCOUNT_API_KEY }}
BLOCKCHAIN_ENDPOINTS: ${{ vars.BLOCKCHAIN_ENDPOINTS }}
BLOCKCHAIN_EXPLORER: ${{ vars.BLOCKCHAIN_EXPLORER }}
BLOCKCHAIN_EXPLORER_BTC: ${{ vars.BLOCKCHAIN_EXPLORER_BTC }}
BLOCKCHAIN_EXPLORER_ETH: ${{ vars.BLOCKCHAIN_EXPLORER_ETH }}
BLOCKCHAIN_EXPLORER_EOS: ${{ vars.BLOCKCHAIN_EXPLORER_EOS }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
DOCUMENTATION: ${{ vars.DOCUMENTATION }}
DGRAPH_URL: ${{ vars.DGRAPH_URL }}
DGRAPH_ROOT_HASH: ${{ vars.DGRAPH_ROOT_HASH }}
DGRAPH_AUTH_KEY: ${{ secrets.DGRAPH_AUTH_KEY }}
GRAPHQL_URI: ${{vars.GRAPHQL_URI}}
ROOT_DAO_ID: ${{vars.ROOT_DAO_ID}}
ELASTIC_SEARCH_URL: ${{ vars.ELASTIC_SEARCH_URL }}
ELASTIC_SEARCH_API_KEY: ${{ secrets.ELASTIC_SEARCH_API_KEY }}
IPFS_URL: ${{ secrets.IPFS_URL }}
IPFS_PROJECT_ID: ${{ secrets.IPFS_PROJECT_ID }}
IPFS_PROJECT_SECRET: ${{ secrets.IPFS_PROJECT_SECRET }}
IPFS_GATEWAY: ${{ secrets.IPFS_GATEWAY }}
HYPHA_TOKEN_SALES_ENCODE_KEY: ${{ secrets.HYPHA_TOKEN_SALES_ENCODE_KEY }}
HYPHA_TOKEN_SALES_URL: ${{ vars.HYPHA_TOKEN_SALES_URL }}
HYPHA_TOKEN_SALES_API_URL: ${{ vars.HYPHA_TOKEN_SALES_API_URL }}
HYPHA_TOKEN_SALES_RPC_URL: ${{ vars.HYPHA_TOKEN_SALES_RPC_URL }}
CAPTCHA_PUBLIC_KEY: ${{ vars.CAPTCHA_PUBLIC_KEY }}
CAPTCHA_HOST: ${{ vars.CAPTCHA_HOST }}
CAPTCHA_NETWORK: ${{ vars.CAPTCHA_NETWORK }}
LOGIN_CONTRACT: ${{ vars.LOGIN_CONTRACT }}
jobs:
build_and_deploy:
name: 'Build and Deploy App'
environment: telosTestNet
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Generate branch name
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: checkout
uses: actions/checkout@v3
- name: Create S3 bucket
run: |
if aws s3api head-bucket --bucket ${{ env.BRANCH_NAME }} 2>/dev/null; then
echo "Bucket exists"
else
aws s3 mb s3://${{ env.BRANCH_NAME }} --region ${{ env.AWS_REGION }}
echo "Bucket created"
fi
- name: Check CloudFront Distribution
run: |
DISTRIBUTION_ID=$(aws cloudfront list-distributions --query "DistributionList.Items[?Aliases.Items[0]=='${{ env.BRANCH_NAME }}'].Id" --output text)
if [ -z "$DISTRIBUTION_ID" ]
then
echo "Creating CloudFront distribution"
aws cloudfront create-distribution \
--origin-domain-name ${{ env.BRANCH_NAME }}.s3.amazonaws.com \
--default-root-object index.html
else
echo "CloudFront distribution exists with ID: $DISTRIBUTION_ID"
echo "::set-output name=cf-dist-id::$DISTRIBUTION_ID"
fi
- name: Get CloudFront Distribution DNS Name
id: get_cf_dns_name
run: |
echo "::set-output name=distribution_dns_name::$(aws cloudfront get-distribution-config --id ${{ steps.create_cloudfront.outputs.cloudfront_distribution_id }} --query 'DistributionConfig.ViewerCertificate.ACMCertificateArn' --output text | cut -d '/' -f 2)"
- name: Create CNAME entry
if: steps.get_cf_dns_name.outputs.distribution_dns_name != ''
run: |
echo ${{ env.BRANCH_NAME }} ${{ steps.get_cf_dns_name.outputs.distribution_dns_name }} >> /etc/hosts
aws route53 change-resource-record-sets --hosted-zone-id ${{ env.AWS_HOSTED_ZONE_ID }} --change-batch '{"Changes":[{"Action":"UPSERT","ResourceRecordSet":{"Name":"${env.BRANCH_NAME}.","Type":"CNAME","TTL":300,"ResourceRecords":[{"Value":"${steps.get_cf_dns_name.outputs.distribution_dns_name}"}]}}]}'
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '16.x'
- run: yarn global add @vue/cli@latest
- run: yarn install
- run: mv public/chain-manifests-prod.json public/chain-manifests.json
- run: mv public/app-manifest-prod.json public/app-manifest.json
- run: yarn build
- name: S3 sync
uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ env.BRANCH_NAME }}
AWS_REGION: ${{ env.AWS_REGION }}
SOURCE_DIR: 'dist/spa'