Skip to content

Commit e7563d0

Browse files
authored
Ci/optimize site deployment (#336)
* chore: remove awesome pages * chore: run cron-check-links only for espressif/developer-portal * feat: improve comments * feat: add cronjob to deploy site every day at midnight
1 parent d222177 commit e7563d0

File tree

9 files changed

+81
-146
lines changed

9 files changed

+81
-146
lines changed

.github/workflows/cron-check-links.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ name: Cron job to check links
44
on:
55
schedule:
66
- cron: '0 2 * * 1'
7-
workflow_dispatch: # Allow manual runs
7+
# Allow manual runs from the Actions tab
8+
workflow_dispatch:
89

910
jobs:
1011
cron-check-links:
12+
if: github.repository_owner == 'espressif'
1113
runs-on: ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@v4
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Workflow for building and deploying a Hugo site to AWS S3 Bucket
2+
name: Deploy Hugo site to AWS S3 Bucket
3+
4+
on:
5+
schedule:
6+
- cron: '5 0 * * *'
7+
# Allow manual runs from the Actions tab
8+
workflow_dispatch:
9+
10+
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
# Allow only one concurrent deployment
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: false
20+
21+
# Default to bash
22+
defaults:
23+
run:
24+
shell: bash
25+
26+
jobs:
27+
build-and-deploy:
28+
if: github.repository_owner == 'espressif'
29+
runs-on: ubuntu-latest
30+
steps:
31+
32+
- name: Install Hugo CLI
33+
env:
34+
HUGO_VERSION: 0.135.0
35+
run: |
36+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
37+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
38+
39+
- name: Check out repo
40+
uses: actions/checkout@v4
41+
with:
42+
submodules: recursive
43+
44+
- name: Build website with Hugo
45+
env:
46+
# For maximum backward compatibility with Hugo modules
47+
HUGO_ENVIRONMENT: production
48+
HUGO_ENV: production
49+
run: |
50+
hugo \
51+
--gc \
52+
--minify
53+
54+
- name: Copy files to AWS S3 with AWS CLI
55+
uses: jakejarvis/s3-sync-action@master
56+
with:
57+
args: --follow-symlinks --delete --exclude "persist/*"
58+
env:
59+
AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }}
60+
SOURCE_DIR: './public'
61+
AWS_REGION: ${{ secrets.AWS_REGION }}
62+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
63+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
64+
65+
invalidate-cache:
66+
needs: build-and-deploy
67+
runs-on: ubuntu-latest
68+
steps:
69+
70+
- name: Invalidate cloudfront cache
71+
uses: chetan/invalidate-cloudfront-action@v2
72+
env:
73+
PATHS: "/*"
74+
DISTRIBUTION: ${{ secrets.CLOUDFRONT_DISTRIBUTION }}
75+
AWS_REGION: ${{ secrets.AWS_REGION }}
76+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
77+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/deploy-hugo-site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
push:
77
branches:
88
- main
9-
# Add an option to run this workflow manually from the Actions tab
9+
# Allow manual runs from the Actions tab
1010
workflow_dispatch:
1111

1212
# Set permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages

content/pages/arduino/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/pages/esp-idf/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/pages/ides/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/pages/nuttx/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/pages/rust/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

content/pages/zephyr/index.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)