-
-
Notifications
You must be signed in to change notification settings - Fork 158
91 lines (81 loc) · 3.05 KB
/
nodejs.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
name: Node.js CI
on:
push:
branches: [ '**' ]
release:
types: [ published ]
pull_request:
branches: [ '**' ]
jobs:
build:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || '' }}
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: ${{ secrets.AWS_REGION }}
SOURCE_DIR: 'dist'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Canvas Dependencies
run: sudo apt-get install xvfb
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Install npm
run: npm install -g npm@8
- name: Install Dependencies
run: npm install
# All the below are deploy-related steps
- name: Extract Branch Name
id: branch_name
if: github.event_name == 'push'
run: echo BRANCH_NAME=${GITHUB_REF/refs\/heads\//} >> $GITHUB_OUTPUT
- name: Build for Distribution
run: xvfb-run --auto-servernum npm run dist
# Append assets to releases
- name: Upload Assets to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
./bundle/dist/browser/*
# Examples:
# 1) PR feature/acme merged into dev
# 2) branch A merged into branch B
# 3) branch A pushed directly to git
- name: Deploy Non-Tag Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'push' && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=60"
env:
DEST_DIR: ${{ steps.branch_name.outputs.BRANCH_NAME }}
# Release is published and deployed into s3://bucket-name/v5.2.2/
- name: Deploy Released Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=2592000"
env:
DEST_DIR: ${{ github.event.release.tag_name }}
# Same release from previous deployed into s3://bucket-name/latest/
- name: Deploy Latest Release
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && github.event.release.prerelease == false && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=1209600"
env:
DEST_DIR: 'latest'
# Publish to NPM
- name: Publish Latest Release
if: github.event_name == 'release' && github.event.release.prerelease == false && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci
# Publish to NPM with prerelease dist-tag
- name: Publish Latest Prerelease
if: github.event_name == 'release' && github.event.release.prerelease && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci -- --dist-tag prerelease