-
Notifications
You must be signed in to change notification settings - Fork 10
85 lines (74 loc) · 2.78 KB
/
gh-pages.yml
File metadata and controls
85 lines (74 loc) · 2.78 KB
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
name: Deploy to GitHub Pages
on:
push:
branches:
- main
- dev
- "*"
# For GitHub OIDC authentication to AWS
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- environment: dev
branch: dev
s3_bucket: devnet-dapp-frontend-build-artifacts
account: 537927626649
- environment: production
branch: main
s3_bucket: mainnet-dapp-frontend-build-artifacts
account: 490721144737
environment: ${{ matrix.environment }}
steps:
# Checkout code
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 https://github.com/actions/checkout/releases/tag/v6.0.2
# Set up Node.js environment
- name: Setup Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 https://github.com/actions/setup-node/releases/tag/v4.4.0
with:
node-version: '22.3'
cache: 'npm'
- name: Extract branch name
id: extract_branch
run: |
if [[ "${GITHUB_REF}" == "refs/heads/"* ]]; then
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
elif [[ "${GITHUB_REF}" == "refs/pull/"* ]]; then
echo "BRANCH_NAME=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=unknown" >> $GITHUB_ENV
fi
# Navigate to the correct working directory and install dependencies
- name: Install dependencies
working-directory: ./
run: npm ci
# Build the project
- name: Build project
working-directory: ./
env:
ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }}
ALGOLIA_API_KEY_READONLY: ${{ secrets.ALGOLIA_API_KEY_READONLY }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
API_BASE_URL: ${{ vars.API_BASE_URL }}
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
export API_BASE_URL=$API_BASE_URL
npm run build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.3.1
with:
role-to-assume: arn:aws:iam::${{ matrix.account }}:role/gha-s3-frontend-push
role-session-name: gha-s3-frontend-push
aws-region: ${{ vars.AWS_ECR_REGION }}
# Upload to S3
- name: Upload to S3
run: |
tar -czf docs-${{ github.sha }}.tar.gz -C build .
aws s3 cp docs-${{ github.sha }}.tar.gz s3://${{ matrix.s3_bucket }}/docs-website/${{ github.sha }}.tar.gz