Deploy to Dev #18
Workflow file for this run
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 to Dev" | |
on: | |
pull_request | |
# push: | |
# branches: | |
# - uswds-redesign | |
jobs: | |
deploy: | |
runs-on: self-hosted | |
steps: | |
# Step 1: Checkout the repo | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install project dependencies | |
run: | | |
sudo dnf -y install ruby3.2 ruby3.2-devel openssl-devel amazon-rpm-config gcc-c++ | |
# Step 3: Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
# node-version: 20 ## Using a .nvmrc file to stay in sync with the repo | |
# Step 2: Set up Ruby | |
- name: Set up ruby | |
run: | | |
ruby -v | |
echo 'export GEM_HOME="$HOME/gems"' >> $GITHUB_ENV | |
echo 'export PATH="$HOME/ec2-user/bin:$HOME/gems/bin:$PATH"' >> $GITHUB_ENV | |
# Step 4: Install Ruby Gems | |
- name: Install jekyll and bundler | |
run: | | |
sudo chmod -R 777 /usr/share | |
sudo gem install jekyll bundler | |
sudo bundle install | |
# Step 5: Install Node.js Dependencies | |
- name: Install npm dependencies | |
run: | | |
npm ci | |
# Step 6: Compile Assets | |
- name: Compile assets with Gulp | |
run: | | |
npm run gulp compile | |
# Step 7: Build Site | |
- name: Build the site | |
env: | |
JEKYLL_ENV: production | |
run: | | |
bundle exec jekyll build --baseurl /${{ github.event.number }} | |
# Step 8: Initialize AWS Connection | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ vars.AWS_REGION }} | |
role-to-assume: arn:aws:iam::${{ secrets.TEST_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions | |
# Step 9: Deploy to S3 | |
- name: Deploy the site | |
run: | | |
aws s3 sync _site/ s3://website-ab2d-east-impl/${{ github.event.number }}/ | |
# Step 10: Invalidate existing cache | |
# - name: Invalidate Cloudfront cache | |
# env: | |
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
# AWS_REGION: us-east-1 | |
# run: | | |
# aws cloudfront create-invalidation \ | |
# --distribution-id ${{ secrets.DISTRIBUTION_ID }} \ | |
# --paths "/*" | |
update-pr: | |
needs: deploy | |
runs-on: self-hosted | |
steps: | |
- name: Comment PR with execution number | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: | | |
## Deployment Success Message | |
URL: [dyx9tyg1h7v8p.cloudfront.net/${{github.event.number}}/](dyx9tyg1h7v8p.cloudfront.net/${{github.event.number}}/) | |
Latest commit: [${{ github.sha }}](https://github.com/${{github.repository}}/commit/${{github.sha}}) | |
comment-tag: preview-link |