-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upload static files to the S3 bucket in AWS
- Loading branch information
Alberto Diaz Dorado
committed
May 16, 2024
1 parent
26820d2
commit 526ff79
Showing
1 changed file
with
63 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,28 +12,84 @@ on: | |
description: 'Source branch' | ||
required: true | ||
|
||
env: | ||
AWS_REGION: ${{ vars.AWS_REGION }} | ||
DEPLOYMENT_ROLE_ARN: ${{ vars.DEPLOYMENT_ROLE_ARN }} | ||
BUCKET_NAME: ${{ vars.BUCKET_NAME }} | ||
|
||
# Required to fetch OIDC token | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build generator and compile site | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/[email protected] | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Nix ❄️ | ||
uses: cachix/install-nix-action@v20 | ||
uses: cachix/install-nix-action@v25 | ||
|
||
- name: Install and setup Cachix 💽 | ||
uses: cachix/cachix-action@v12 | ||
uses: cachix/cachix-action@v14 | ||
with: | ||
name: munihac-website | ||
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' | ||
|
||
- name: Build Generator and Site 👷 | ||
run: | | ||
nix-build | ||
cp -RL result result-with-changed-permissions | ||
chmod -R +w result-with-changed-permissions/ | ||
- name: Upload build artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: result-with-changed-permissions/ | ||
|
||
deploy-github-pages: | ||
name: Deploy to GitHub Pages | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout 🛎️ | ||
uses: actions/checkout@v4 | ||
|
||
- name: Download build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: result | ||
|
||
- name: Deploy 🚀 | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
BRANCH: master | ||
FOLDER: result-with-changed-permissions | ||
branch: master | ||
folder: result/ | ||
|
||
deploy-aws: | ||
name: Deploy to AWS | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download build artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: build-artifacts | ||
path: result | ||
|
||
- name: Obtain OIDC token | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-to-assume: ${{ env.DEPLOYMENT_ROLE_ARN }} | ||
|
||
- name: Deploy static site to S3 bucket | ||
run: | | ||
aws sts get-caller-identity | ||
aws s3api list-objects --bucket ${{ env.BUCKET_NAME }} --debug | ||
aws s3 sync ./result/ s3://${{ env.BUCKET_NAME }} --delete |