-
Notifications
You must be signed in to change notification settings - Fork 2
79 lines (67 loc) · 2.23 KB
/
cdn_deploy.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
name: 🚩 Deploy to CDN
on:
push:
branches:
- main
tags:
- "*"
# Workflow is triggered only if src changes
paths:
- src/**
# Allow manual trigger (workflow_dispatch)
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
# These permissions are needed to interact with GitHub's OIDC Token endpoint
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
cache-dependency-path: "pnpm-lock.yaml"
- name: Install dependencies
working-directory: .
run: CI=true pnpm install
- name: Build Dist
working-directory: .
run: pnpm build
- name: Upload to GH Pages
continue-on-error: true
run: |
# Checkout to gh-pages
mkdir tmp_pages
cd tmp_pages
git init --initial-branch=gh-pages
git config user.name svchot
git config user.email [email protected]
git pull https://x-access-token:[email protected]/${{ github.repository }}.git gh-pages
# Upload latest components dist
mkdir -p dist
cp ${{ github.workspace }}/dist/index.js dist/core.js
# Push content to gh-pages
git add .
git commit -m "docs: update component dist to latest"
git push --set-upstream https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:gh-pages
- name: Configure AWS Creds
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.ORG_AWS_ACCOUNT_ID }}:role/Github-AWS-OIDC
aws-region: us-east-1
- name: Upload to S3
env:
# latest for main branch, else tag name
S3_PATH: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
run: |
# Push dist to correct S3 dir
aws s3 cp --recursive ${{ github.workspace }}/dist/ \
s3://${{ vars.S3_BUCKET_NAME }}/${{ env.S3_PATH }}/