-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (79 loc) · 2.77 KB
/
pipeline.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
name: Deploy
on:
workflow_dispatch:
inputs:
environment:
description: 'Which environment to deploy to [dev|prod].'
default: dev
required: true
jobs:
deploy_to_s3:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
PUBLIC_URL: ''
steps:
- uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2.4.1
with:
node-version: 16
- name: Print env
run: env
- name: Install dependencies
run: yarn
- name: Build
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }}
run: yarn run build:dev
- name: Deploy to dev
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }}
uses: reggionick/s3-deploy@v3
with:
folder: build
bucket: airdrop.thechaindata.com
bucket-region: ap-southeast-2
invalidation: /*
dist-id: ${{ secrets.CLOUDFRONT_ID_DEV }}
delete-removed: false
no-cache: true
private: true
- name: Build for production
if: github.event.inputs.environment == 'prod'
run: npm run build
- name: Deploy to prod
if: github.event.inputs.environment == 'prod'
uses: reggionick/s3-deploy@v3
with:
folder: build
bucket: airdrop.subquery.foundation
bucket-region: ap-southeast-2
invalidation: /*
dist-id: ${{ secrets.CLOUDFRONT_ID_PROD }}
delete-removed: false
no-cache: true
private: true
clean_cloudfront_cache:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: clean cache dev
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }}
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_ID_DEV }}
PATHS: '/*'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
- name: clean cache prod
if: ${{ github.event.inputs.environment == 'prod' || !github.event.inputs.environment }}
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.CLOUDFRONT_ID_PROD }}
PATHS: '/*'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'