-
Notifications
You must be signed in to change notification settings - Fork 6
66 lines (53 loc) · 2.29 KB
/
deploy-showcase-pr-s3.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
name: Build & Deploy Showcase (PR)
permissions:
contents: read
packages: read
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
build-deploy-demo-pr:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_VIVID_DEMO_PRS_ACCESS }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_VIVID_DEMO_PRS_SECRET }}
AWS_DEFAULT_REGION: us-east-1
steps:
- name: Add PR deploy URL comment
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
env:
URL: ${{ github.event.pull_request.comments_url }}
run: |
curl -X POST $URL -H "Content-Type: application/json" -H "Authorization: token $GITHUB_TOKEN" \
--data '{ "body": ":rocket:\n\nLatest __successful__ build of the PR deployed [here](https://${{ secrets.TMP_PR_DEPLOYMENT_BASE_URL }}/${{ github.event.number }}/index.html).\n\n:rocket:" }'
- name: Checkout
uses: actions/checkout@v2
- name: Setup NodeJS 14
uses: actions/setup-node@v4
with:
node-version: 14
registry-url: https://npm.pkg.github.com
- name: Install yarn
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
- name: Cache yarn dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
**/node_modules
key: vivid-cache-yarn-${{ hashFiles('**/package.json') }}
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --network-timeout 100000
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Build storybook
run: yarn storybook:build base-url=${{ github.event.number }}
- name: Deploy showcase under PR ID (${{ github.event.number }})
run: aws s3 sync ./.out/ s3://${{ secrets.AWS_VIVID_DEMO_PRS_BUCKET }}/${{ github.event.number }}
- name: Invalidate CloudFront distribution root object's cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_VIVID_DEMO_PRS_DISTRIBUTION }} --paths "/${{ github.event.number }}/*"