Skip to content

Commit cd9b452

Browse files
lesbaaLes Moffat
andauthored
RD-1231 Update GH Actions with CF CDN deploy (#33)
* RD-1231 Update GH Actions with CF CDN deploy * RD-1231 Use correct node version * RD-1231 Use correct build command in GH CF deploy action --------- Co-authored-by: Les Moffat <les.moffat@maptiler.com>
1 parent 25d8cd5 commit cd9b452

2 files changed

Lines changed: 81 additions & 3 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,22 @@ jobs:
2020
with:
2121
node-version: 20
2222
registry-url: https://registry.npmjs.org/
23-
- run: npm ci
24-
- run: npm run make
25-
23+
24+
- name: Clear NPM cache
25+
run: npm cache clean --force
26+
27+
- name: Install dependencies and build
28+
run: npm ci
29+
30+
- name: Make release
31+
run: npm run build
32+
id: makeRelease
33+
34+
- name: Fail job if makeRelease failed
35+
if: steps.makeRelease.outcome == 'failure'
36+
run: exit 1
37+
38+
id: check-build-status
2639
- name: Publish NPM package (regular)
2740
if: "!github.event.release.prerelease"
2841
run: |
@@ -36,3 +49,17 @@ jobs:
3649
npm publish --tag next
3750
env:
3851
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
52+
53+
- name: Get Package version
54+
id: version
55+
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
56+
- name: Publish to CDN Cloudflar R2
57+
uses: ryand56/r2-upload-action@v1.4
58+
with:
59+
r2-account-id: ${{ secrets.CDN_MAPTILER_ACCOUNT_ID }}
60+
r2-access-key-id: ${{ secrets.CDN_MAPTILER_ACCESS_KEY_ID }}
61+
r2-secret-access-key: ${{ secrets.CDN_MAPTILER_SECRET_ACCESS_KEY }}
62+
r2-bucket: cdn-storage
63+
source-dir: build
64+
destination-dir: leaflet-maptilersdk/v${{ env.PACKAGE_VERSION }}/
65+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
pull_request:
8+
types: [opened]
9+
10+
jobs:
11+
test-build-and-publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.release.target_commitish }}
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
registry-url: https://registry.npmjs.org/
23+
24+
- name: Clear NPM cache
25+
run: npm cache clean --force
26+
27+
- name: Install dependencies and build
28+
run: npm ci
29+
30+
- name: Make release
31+
run: npm run build
32+
id: makeRelease
33+
34+
- name: Fail job if makeRelease failed
35+
if: steps.makeRelease.outcome == 'failure'
36+
run: exit 1
37+
38+
id: check-build-status
39+
- name: Publish NPM package (regular)
40+
if: "!github.event.release.prerelease"
41+
run: |
42+
npm publish --dry-run
43+
env:
44+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
45+
46+
- name: Publish NPM package (pre-release)
47+
if: "github.event.release.prerelease"
48+
run: |
49+
npm publish --tag next --dry-run
50+
env:
51+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

0 commit comments

Comments
 (0)