|
12 | 12 | description: 'Source branch' |
13 | 13 | required: true |
14 | 14 |
|
| 15 | +env: |
| 16 | + AWS_REGION: ${{ vars.AWS_REGION }} |
| 17 | + DEPLOYMENT_ROLE_ARN: ${{ vars.DEPLOYMENT_ROLE_ARN }} |
| 18 | + BUCKET_NAME: ${{ vars.BUCKET_NAME }} |
| 19 | + |
| 20 | +# Required to fetch OIDC token |
| 21 | +permissions: |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + |
15 | 25 | jobs: |
16 | 26 | build: |
17 | | - name: Build generator and compile site |
| 27 | + name: Build |
18 | 28 | runs-on: ubuntu-latest |
19 | 29 | steps: |
20 | 30 | - name: Checkout 🛎️ |
21 | | - |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
22 | 33 | - name: Install Nix ❄️ |
23 | | - uses: cachix/install-nix-action@v20 |
| 34 | + uses: cachix/install-nix-action@v25 |
| 35 | + |
24 | 36 | - name: Install and setup Cachix 💽 |
25 | | - uses: cachix/cachix-action@v12 |
| 37 | + uses: cachix/cachix-action@v14 |
26 | 38 | with: |
27 | 39 | name: munihac-website |
28 | 40 | signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' |
| 41 | + |
29 | 42 | - name: Build Generator and Site 👷 |
30 | 43 | run: | |
31 | 44 | nix-build |
32 | 45 | cp -RL result result-with-changed-permissions |
33 | 46 | chmod -R +w result-with-changed-permissions/ |
| 47 | +
|
| 48 | + - name: Upload build artifacts |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: build-artifacts |
| 52 | + path: result-with-changed-permissions/ |
| 53 | + |
| 54 | + deploy-github-pages: |
| 55 | + name: Deploy to GitHub Pages |
| 56 | + needs: build |
| 57 | + runs-on: ubuntu-latest |
| 58 | + steps: |
| 59 | + - name: Checkout 🛎️ |
| 60 | + uses: actions/checkout@v4 |
| 61 | + |
| 62 | + - name: Download build artifacts |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + name: build-artifacts |
| 66 | + path: result |
| 67 | + |
34 | 68 | - name: Deploy 🚀 |
35 | 69 | uses: JamesIves/github-pages-deploy-action@v4 |
36 | 70 | with: |
37 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
38 | | - BRANCH: master |
39 | | - FOLDER: result-with-changed-permissions |
| 71 | + branch: master |
| 72 | + folder: result/ |
| 73 | + |
| 74 | + deploy-aws: |
| 75 | + name: Deploy to AWS |
| 76 | + needs: build |
| 77 | + runs-on: ubuntu-latest |
| 78 | + steps: |
| 79 | + - name: Download build artifacts |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: build-artifacts |
| 83 | + path: result |
| 84 | + |
| 85 | + - name: Obtain OIDC token |
| 86 | + uses: aws-actions/configure-aws-credentials@v4 |
| 87 | + with: |
| 88 | + aws-region: ${{ env.AWS_REGION }} |
| 89 | + role-to-assume: ${{ env.DEPLOYMENT_ROLE_ARN }} |
| 90 | + |
| 91 | + - name: Deploy static site to S3 bucket |
| 92 | + run: | |
| 93 | + aws sts get-caller-identity |
| 94 | + aws s3api list-objects --bucket ${{ env.BUCKET_NAME }} --debug |
| 95 | + aws s3 sync ./result/ s3://${{ env.BUCKET_NAME }} --delete |
0 commit comments