Skip to content

Commit 2c28779

Browse files
committed
Update publish_website_to_aws.yml github action
1 parent 76e9e59 commit 2c28779

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish website to aws
2+
on: [pull_request]
3+
4+
jobs:
5+
build-deploy:
6+
name: Build
7+
runs-on: ubuntu-latest
8+
permissions: write-all
9+
10+
environment:
11+
name: aws
12+
url: ${{ steps.aws-deployment-url.outputs.s3_url }}
13+
14+
strategy:
15+
matrix:
16+
node-version: [lts/*]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install Gulp
30+
run: npm install -g gulp-cli
31+
32+
- name: Install other dependencies
33+
run: npm install
34+
35+
- name: Build the website
36+
run: gulp web
37+
38+
- name: Configure AWS Credentials
39+
uses: aws-actions/configure-aws-credentials@v4
40+
with:
41+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
42+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
43+
aws-region: us-east-1
44+
45+
- name: Deploy site to S3 bucket
46+
run: aws s3 sync build/gh-pages/ s3://${{ vars.AWS_BUCKET_NAME }}/${{ github.event.pull_request.head.sha }}/ --acl public-read
47+
48+
- name: Save aws s3 deployment url for aws environment
49+
id: aws-deployment-url
50+
run: |
51+
echo "s3_url=https://${{ vars.AWS_BUCKET_NAME }}.s3.us-east-1.amazonaws.com/${{ github.event.pull_request.head.sha }}/web/viewer.html?file=${{ vars.TEST_PDF }}" >> $GITHUB_OUTPUT
52+
53+
- name: Comment deployed url to PR
54+
if: github.event_name == 'pull_request'
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
github.rest.issues.createComment({
59+
issue_number: context.issue.number,
60+
owner: context.repo.owner,
61+
repo: context.repo.repo,
62+
body: '${{ steps.aws-deployment-url.outputs.s3_url }}'
63+
})

0 commit comments

Comments
 (0)