Merge pull request #28 from SharinPix/remove-additional-unused-featur… #252
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |