-
Notifications
You must be signed in to change notification settings - Fork 40
141 lines (123 loc) · 4.46 KB
/
publish-HOWTOs.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
name: Publish HOWTOs
on:
- push
- workflow_dispatch
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: false
jobs:
build:
name: Build and package HOWTOs
runs-on: ubuntu-latest
env:
RELEASE_BRANCH_PREFIX: 'workspace/'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node 18
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org
scope: '@openfin'
- name: Restore root node_modules from cache
id: node-cache
uses: actions/cache@v4
with:
path: node_modules
key: node-modules-${{ hashFiles('package-lock.json') }}
- name: Install dependencies
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm ci
- name: Build packages
run: npm run build
- name: Package for publishing (GitHub Pages)
run: npm run package
env:
PKG_HOWTOS_LOCATION: github
PKG_HOWTOS_PATH: ${{ github.ref_name }}
- name: Package for publishing (AWS s3 CDN)
if: ${{ startsWith(github.ref_name, env.RELEASE_BRANCH_PREFIX) }}
run: npm run package
env:
PKG_HOWTOS_LOCATION: aws
PKG_HOWTOS_PATH: ${{ github.ref_name }}
- name: Upload artifacts (GitHub Pages)
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: workflow-howtos-github
path: public-github/
retention-days: 1
- name: Upload artifacts (AWS s3 CDN)
if: ${{ startsWith(github.ref_name, env.RELEASE_BRANCH_PREFIX) }}
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
name: workflow-howtos-aws
path: public-aws/
retention-days: 1
publish-gh:
name: Publish HOWTOs (GitHub Pages)
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: workflow-howtos-github
path: public-github/
- name: Publish
uses: JamesIves/[email protected]
with:
branch: gh-pages # Target branch to deploy to
folder: public-github # Source folder to deploy
target-folder: ${{ github.ref_name }} # Target folder to deploy to
publish-aws:
if: ${{ startsWith(github.ref_name, 'workspace/') }}
name: Publish HOWTOs (AWS s3 CDN)
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: workflow-howtos-aws
path: public-aws/
- name: Get Archive zip from GH URL
uses: suisei-cn/actions-download-file@v1
id: downloadfile
with:
url: https://github.com/built-on-openfin/workspace-starter/archive/refs/heads/${{ github.ref_name }}.zip
target: public-aws/
- name: Publish
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
# The bucket name should match the https host name in
# scripts/package.js:URLBaseMap['aws'].
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} # Target bucket to deploy to
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: public-aws # Source folder to deploy
DEST_DIR: workspace-starter/${{ github.ref_name }} # Target folder to deploy to
- name: Copy zip to s3 folder
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
source: s3://samples.openfin.co/workspace-starter/${{ github.ref_name }}/
dest: s3://samples.openfin.co/workspace-starter/
flags: --recursive --exclude "*" --include "v*.zip" --acl public-read
- name: Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }}
PATHS: '/workspace-starter/*'
AWS_REGION: 'us-east-1'
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}