-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (126 loc) · 4.95 KB
/
pull_request.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: MyCryptoBuilds PR
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'us-east-1'
on:
pull_request:
branches:
- '*'
jobs:
Sha:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
## Set sha in env for pathPrefix
- name: Set SHA number
run: echo "GITHUB_SHA=$GITHUB_SHA" >> $GITHUB_ENV
shell: bash
- name: Retrieve engines' versions from package.json to env variables
id: engines
run: echo "##[set-output name=NVMRC;]$(cat package.json | grep '\"node\":' | sed 's/^ *//;s/ *$//;s/\"node\":\ \"//;s/\",//' )"
- name: Setup node ${{ steps.engines.outputs.NODE_VERSION }}
uses: actions/setup-node@main
with:
node-version: ${{ steps.engines.outputs.NODE_VERSION }}
- name: Cache depedendencies
id: cache
uses: actions/cache@v1
with:
path: node_modules
## Check cache based on yarn.lock hashfile
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.cache-name }}-
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install dependencies
## If no cache is found, install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn
- name: yarn build sha-build - pr
if: github.event_name == 'pull_request'
run: yarn build:staging
env:
PATH_PREFIX: '/${{ github.event.pull_request.head.sha }}'
- name: yarn build sha-build - push
if: github.event_name == 'push'
run: yarn build:staging
env:
PATH_PREFIX: '/${{ env.GITHUB_SHA }}'
- name: S3 Sync - SHA Push
uses: jakejarvis/[email protected]
if: github.event_name == 'push'
with:
args: --acl public-read --cache-control max-age=0 --follow-symlinks --exclude '.git/*'
env:
DEST_DIR: ${{ env.GITHUB_SHA }}
SOURCE_DIR: 'public'
- name: S3 Sync - SHA PR
uses: jakejarvis/[email protected]
if: github.event_name == 'pull_request'
with:
args: --acl public-read --cache-control max-age=0 --follow-symlinks --exclude '.git/*'
env:
DEST_DIR: ${{ github.event.pull_request.head.sha }}
SOURCE_DIR: 'public'
Pr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
# Fetch the PR number to use it with AWS
- name: Set PR_NUMBER
run: |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
- name: Set E2E_BASE_URL
if: github.ref != 'refs/heads/master'
run: |
E2E_BASE_URL=$( echo https://landing.mycryptobuilds.com/pr/${PR_NUMBER}/# )
echo $E2E_BASE_URL
echo "E2E_BASE_URL=$E2E_BASE_URL" >> $GITHUB_ENV
- name: Retrieve engines' versions from package.json to env variables
id: engines
run: echo "##[set-output name=NVMRC;]$(cat package.json | grep '\"node\":' | sed 's/^ *//;s/ *$//;s/\"node\":\ \"//;s/\",//' )"
- name: Setup node ${{ steps.engines.outputs.NODE_VERSION }}
uses: actions/setup-node@main
with:
node-version: ${{ steps.engines.outputs.NODE_VERSION }}
- name: Cache depedendencies
id: cache
uses: actions/cache@v1
with:
path: node_modules
## Check cache based on yarn.lock hashfile
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.cache-name }}-
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install dependencies
## If no cache is found, install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: yarn
- name: yarn build pr
if: github.event_name == 'pull_request'
run: yarn build:staging
env:
PATH_PREFIX: '/pr/${{ env.PR_NUMBER }}'
- name: S3 Sync - PR Number
uses: jakejarvis/[email protected]
if: github.event_name == 'pull_request'
with:
args: --acl public-read --cache-control max-age=0 --follow-symlinks --delete --exclude '.git/*'
env:
DEST_DIR: 'pr/${{ env.PR_NUMBER }}'
SOURCE_DIR: 'public'
- name: Mycrypto-bot trigger
if: github.event_name == 'pull_request'
run: aws sns publish --topic-arn ${{ secrets.SNS_TOPIC_MYCRYPTO_BOT }} --region us-east-2 --message $(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
# Launch E2E tests. When in pull request it runs against the PR's mycryptobuilds url.
- name: E2E - run
if: github.event_name == 'pull_request'
run: yarn test:e2e