Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Translation - isolation #2230

Translation - isolation

Translation - isolation #2230

name: Eleventy Build PR Site
on:
pull_request:
branches-ignore:
- dependabot/**
- dependabotprs
types:
- opened
- synchronize
- ready_for_review
- reopened
permissions:
id-token: write
contents: read
pull-requests: write
jobs:
build_deploy:
runs-on: ubuntu-latest
steps:
- uses: n1hility/cancel-previous-runs@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
- name: Escape branch name for URL
shell: bash
run: echo "URLSAFE_BRANCH_NAME=$(echo ${BRANCH_NAME} | sed 's|[^A-Za-z0-9-]|-|g' | sed -E 's|-*([A-Za-z0-9]*.*[A-Za-z0-9]+)-*|\1|' | cut -c 1-63)" >> $GITHUB_ENV
- name: Report escaped branch name
shell: bash
run: echo ${URLSAFE_BRANCH_NAME}
- name: Build 11ty
run: |
mkdir dist
npm install
DOMAIN=${URLSAFE_BRANCH_NAME}.pr.covid19.ca.gov npm run build
- name: Write robots.txt
run: |
echo 'User-agent: *' > docs/robots.txt
echo 'Disallow: /' >> docs/robots.txt
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1
- name: Deploy to S3
run: aws s3 sync --acl public-read --follow-symlinks --delete ./docs s3://pr.covid19.ca.gov/pr/${URLSAFE_BRANCH_NAME}
- name: invalidate Cloudfront
run: AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id E3JRVVFYGDA1AM --paths "/*"
- name: Post URL to PR
uses: mshick/add-pr-comment@v2
with:
message: |
Preview site available at [${{ env.URLSAFE_BRANCH_NAME }}.pr.covid19.ca.gov](https://${{ env.URLSAFE_BRANCH_NAME }}.pr.covid19.ca.gov/).
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: false