-
Notifications
You must be signed in to change notification settings - Fork 23
94 lines (81 loc) · 2.62 KB
/
deploy-hugo-site.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
# Workflow for building and deploying a Hugo site to AWS S3 Bucket
name: Deploy Hugo site to AWS S3 Bucket
on:
# Run on pushes to the default branch
push:
branches:
- main
paths-ignore:
- content/blog/nuttx-getting-started/index.md
# Add an option to run this workflow manually from the Actions tab
workflow_dispatch:
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
# Default to bash
defaults:
run:
shell: bash
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1
with:
args: --no-progress --include-fragments --exclude-path ./themes/ --exclude-path ./layouts/ .
# Fail action on broken links
fail: true
build-and-deploy:
needs: check-links
runs-on: ubuntu-latest
steps:
- name: Install Hugo CLI
env:
HUGO_VERSION: 0.120.4
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: Check out repo
uses: actions/checkout@v4
with:
submodules: recursive
- name: Build website with Hugo
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify
- name: Copy files to AWS S3 with AWS CLI
uses: jakejarvis/s3-sync-action@master
with:
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }}
SOURCE_DIR: './public'
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
invalidate-cache:
needs: build-and-deploy
runs-on: ubuntu-latest
steps:
- name: Invalidate cloudfront cache
uses: chetan/invalidate-cloudfront-action@v2
env:
PATHS: "/*"
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}