Skip to content

Commit 526ff79

Browse files
author
Alberto Diaz Dorado
committed
Udate github action
* Upload static files to the S3 bucket in AWS
1 parent 26820d2 commit 526ff79

File tree

1 file changed

+63
-7
lines changed

1 file changed

+63
-7
lines changed

.github/workflows/main.yml

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,84 @@ on:
1212
description: 'Source branch'
1313
required: true
1414

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+
1525
jobs:
1626
build:
17-
name: Build generator and compile site
27+
name: Build
1828
runs-on: ubuntu-latest
1929
steps:
2030
- name: Checkout 🛎️
21-
uses: actions/[email protected]
31+
uses: actions/checkout@v4
32+
2233
- name: Install Nix ❄️
23-
uses: cachix/install-nix-action@v20
34+
uses: cachix/install-nix-action@v25
35+
2436
- name: Install and setup Cachix 💽
25-
uses: cachix/cachix-action@v12
37+
uses: cachix/cachix-action@v14
2638
with:
2739
name: munihac-website
2840
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
41+
2942
- name: Build Generator and Site 👷
3043
run: |
3144
nix-build
3245
cp -RL result result-with-changed-permissions
3346
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+
3468
- name: Deploy 🚀
3569
uses: JamesIves/github-pages-deploy-action@v4
3670
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

Comments
 (0)