-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (111 loc) · 3.38 KB
/
deploy_js.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
name: Deploy schematic-js
on:
push:
branches:
- main
paths:
- js/**
workflow_dispatch:
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Yarn install
working-directory: ./js
run: yarn install
- name: Lint
working-directory: ./js
run: yarn lint
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Yarn install
working-directory: ./js
run: yarn install
- name: Test
working-directory: ./js
run: yarn test
deploy:
name: Browser Deploy
runs-on: ubuntu-latest
needs: ["test", "lint"]
env:
AWS_REGION: "us-east-1"
CDN_DISTRIBUTION_ID: "EIY5G2ECS6996"
S3_BUCKET: "schematic-cdn"
steps:
- uses: actions/checkout@v3
- name: Set Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Yarn install
working-directory: ./js
run: yarn install
- name: Build browser bundle
working-directory: ./js
run: yarn build:browser
- name: Configure 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: ${{ env.AWS_REGION }}
- name: Get package version
id: package
run: |
echo "::set-output name=version::$(node -p "require('./package.json').version")"
working-directory: ./js
- name: Deploy browser build
run: |
aws s3 cp --acl=public-read dist/schematic.browser.js s3://$S3_BUCKET/js/schematic.js
aws s3 cp --acl=public-read dist/schematic.browser.js s3://$S3_BUCKET/js/schematic.${{ steps.package.outputs.version }}.js
aws configure set preview.cloudfront true
aws cloudfront create-invalidation --distribution-id ${{ env.CDN_DISTRIBUTION_ID }} --paths "/js/schematic.js" "/js/schematic.${{ steps.package.outputs.version }}.js"
working-directory: ./js
publish:
name: NPM Publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
needs: ["test", "lint"]
steps:
- uses: actions/checkout@v4
- name: Set Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Yarn install
working-directory: ./js
run: yarn install
- name: Build
working-directory: ./js
run: yarn build
- name: Set up .npmrc
run: touch .npmrc && echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: ./js
- run: yarn publish --access public
working-directory: ./js
notify_slack:
name: Notify Slack
runs-on: ubuntu-latest
needs: [deploy, publish]
steps:
- uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_TITLE: Updated schematic-js
SLACK_ICON: https://schematic-public-assets.s3.amazonaws.com/logos/logo-transparent.png