Skip to content

Commit

Permalink
Move blog.lucascantor.com from GitHub Pages to AWS S3 (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascantor authored Apr 16, 2024
1 parent 2ac9e5c commit 1f57059
Showing 1 changed file with 19 additions and 25 deletions.
44 changes: 19 additions & 25 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Eleventy site and deploy it to GitHub Pages
name: Build Eleventy site and deploy it to AWS S3

on:
# Runs on pushes targeting the master branch
Expand All @@ -8,20 +8,24 @@ on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
env:
AWS_ROLE_ARN: 'arn:aws:iam::042672036044:role/github-actions-sts-assumption-role'
AWS_S3_BUCKET_NAME: 'blog.lucascantor.com'
AWS_REGION: 'us-east-1'

# Sets required permissions of the GITHUB_TOKEN
permissions:
contents: write
pages: write
id-token: write
contents: read # Required for actions/checkout
id-token: write # Required for requesting the JWT

# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Build job
build:
# Build and deploy job
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -32,27 +36,17 @@ jobs:
node-version: 'node'
check-latest: true

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Install dependencies & build
run: |
npm install
npm run build-gh-pages
npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
path: ./_site
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Deploy to S3
run: |
aws s3 sync ./_site s3://${{ env.AWS_S3_BUCKET_NAME }}/ --delete

0 comments on commit 1f57059

Please sign in to comment.