forked from mozilla/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (67 loc) · 2.57 KB
/
publish_website_to_aws.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
name: Deploy Website to AWS
on:
pull_request:
types: [opened, synchronize, reopened]
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies
run: |
npm ci
npm install -g gulp-cli
- name: Build the website
run: gulp web
- name: Configure AWS credentials (Development)
if: github.event_name == 'pull_request'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTION_ROLE_ARN_DEV }}
aws-region: us-east-1
role-session-name: GitHubActionsSession
- name: Set Deployment Variables
run: |
echo "DATETIME=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "SHORT_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV
- name: Deploy to Development Bucket
if: github.event_name == 'pull_request'
run: |
aws s3 sync build/gh-pages/ s3://${{ vars.AWS_BUCKET_NAME }}/pdfjs/${{ env.DATETIME }}-${{ env.SHORT_HASH }}/ --acl public-read
- name: Comment deployment URL on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const url = `https://${{ vars.AWS_BUCKET_NAME }}.s3.us-east-1.amazonaws.com/pdfjs/${process.env.DATETIME}-${process.env.SHORT_HASH}/web/viewer.html?file=${{ vars.TEST_PDF }}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `${url}`
});
- name: Configure AWS credentials (Production)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_GITHUB_ACTION_ROLE_ARN }}
aws-region: us-east-1
role-session-name: GitHubActionsSession
- name: Deploy to Production Bucket
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
aws s3 sync build/gh-pages/ ${{ secrets.AWS_PRODUCTION_BUCKET_CDN }}/pdfjs/${{ env.DATETIME }}-${{ env.SHORT_HASH }}/ --acl public-read