-
Notifications
You must be signed in to change notification settings - Fork 2
96 lines (82 loc) · 2.29 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Build and deploy site
on:
push:
branches:
- gh-pages-source
schedule:
- cron: '0 3 1 * *' # monthly
workflow_dispatch:
inputs:
source_branch:
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
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Install Nix ❄️
uses: cachix/install-nix-action@v20
- name: Install and setup Cachix 💽
uses: cachix/cachix-action@v12
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: 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/
deploy-aws:
name: Deploy to AWS
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: 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