feat: ci #1
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
name: Hugo s3 deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Hugo CLI | |
run: | | |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \ | |
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb | |
- name: Build | |
run: hugo --minify --destination dist | |
- name: Archive build directory | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
deploy-prod: | |
environment: | |
name: Production | |
# only runs when the branch is main | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: dist | |
path: dist | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
role-to-assume: ${{ secrets.IAM_DEPLOYER_ROLE }} | |
role-session-name: github_federated_aws | |
aws-region: ${{ vars.AWS_REGION }} | |
- name: Deploy Site to S3 | |
env: | |
AWS_S3_BUCKET : ${{ secrets.AWS_S3_BUCKET }} | |
run: | | |
aws s3 sync --delete --sse AES256 dist/ $AWS_S3_BUCKET |