Skip to content

Commit c5045f7

Browse files
authored
Update GitHub actions (#1456)
* util: Update release action * util: Update pull request action
1 parent edfda0e commit c5045f7

File tree

2 files changed

+84
-25
lines changed

2 files changed

+84
-25
lines changed

.github/workflows/pull_request.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,74 @@ name: Pull request
22

33
on: pull_request
44

5+
permissions:
6+
contents: read # Read access for checkout
7+
58
jobs:
69
build:
710
name: Build docs
811
runs-on: ubuntu-24.04-4core
912
steps:
1013
- name: Check out code
11-
uses: actions/checkout@v3
14+
uses: actions/checkout@v4
15+
1216
- name: Editor config
1317
uses: snow-actions/eclint@v1.0.1
1418
continue-on-error: true
19+
1520
- name: Set up Go
16-
uses: actions/setup-go@v3
21+
uses: actions/setup-go@v5
1722
with:
18-
go-version: "~1.23"
23+
go-version-file: go.mod
24+
1925
- name: Get Go module cache directory path
2026
id: go-module-cache-dir-path
21-
run: echo "::set-output name=dir::$(go env GOMODCACHE)"
27+
run: echo "dir=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
28+
2229
- name: Initialize Go module cache
23-
uses: actions/cache@v3
30+
uses: actions/cache@v4
2431
with:
2532
path: ${{ steps.go-module-cache-dir-path.outputs.dir }}
2633
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2734
restore-keys: |
2835
${{ runner.os }}-go-
36+
2937
- name: Download Go dependencies
3038
run: make go.deps
39+
3140
- name: Set up Node
32-
uses: actions/setup-node@v3
41+
uses: actions/setup-node@v4
3342
with:
34-
node-version: "~16"
43+
node-version: "~20"
44+
3545
- name: Get Yarn cache directory path
3646
id: yarn-cache-dir-path
37-
run: echo "::set-output name=dir::$(npx yarn cache dir)"
47+
run: echo "dir=$(npx yarn cache dir)" >> $GITHUB_OUTPUT
48+
3849
- name: Initialize Yarn module cache
39-
uses: actions/cache@v3
50+
uses: actions/cache@v4
4051
with:
4152
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
4253
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4354
restore-keys: |
4455
${{ runner.os }}-yarn-
56+
4557
- name: Download Yarn dependencies
4658
run: make js.deps
59+
4760
- name: Initialize Hugo binary cache
4861
id: cache-hugo
49-
uses: actions/cache@v3
62+
uses: actions/cache@v4
5063
with:
5164
path: hugo.linux
5265
key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.sum') }}
5366
restore-keys: |
5467
${{ runner.os }}-hugo-
68+
5569
- name: Build Hugo binary
5670
if: steps.cache-hugo.outputs.cache-hit != 'true'
5771
run: make hugo.linux
72+
5873
- name: Build docs
5974
run: make build.public
6075
env:
@@ -68,3 +83,10 @@ jobs:
6883
HUGO_PARAMS_SEARCH_APIKEY: ${{ secrets.HUGO_PARAMS_SEARCH_APIKEY }}
6984
HUGO_PARAMS_SEARCH_ENABLED: true
7085
HUGO_PARAMS_SEARCH_INDEX: thethingsstack
86+
87+
- name: Validate build output
88+
run: |
89+
if [ ! -d "public" ]; then
90+
echo "Error: Build output directory 'public' not found"
91+
exit 1
92+
fi

.github/workflows/release.yml

Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,58 +5,74 @@ on:
55
branches:
66
- master
77

8+
permissions:
9+
contents: read # Read access for checkout
10+
pages: write # Write access to deploy to GitHub Pages
11+
812
jobs:
913
release:
1014
name: Release docs
1115
runs-on: ubuntu-24.04-4core
16+
timeout-minutes: 10
1217
steps:
1318
- name: Check out code
14-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
1520
with:
1621
fetch-depth: 0
22+
1723
- name: Set up Go
18-
uses: actions/setup-go@v3
24+
uses: actions/setup-go@v5
1925
with:
20-
go-version: "~1.23"
26+
go-version-file: go.mod
27+
2128
- name: Get Go module cache directory path
2229
id: go-module-cache-dir-path
23-
run: echo "::set-output name=dir::$(go env GOMODCACHE)"
30+
run: echo "dir=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
31+
2432
- name: Initialize Go module cache
25-
uses: actions/cache@v3
33+
uses: actions/cache@v4
2634
with:
2735
path: ${{ steps.go-module-cache-dir-path.outputs.dir }}
2836
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
2937
restore-keys: |
3038
${{ runner.os }}-go-
39+
3140
- name: Download Go dependencies
3241
run: make go.deps
42+
3343
- name: Set up Node
34-
uses: actions/setup-node@v3
44+
uses: actions/setup-node@v4
3545
with:
36-
node-version: "~16"
46+
node-version: "~20"
47+
3748
- name: Get Yarn cache directory path
3849
id: yarn-cache-dir-path
39-
run: echo "::set-output name=dir::$(npx yarn cache dir)"
50+
run: echo "dir=$(npx yarn cache dir)" >> $GITHUB_OUTPUT
51+
4052
- name: Initialize Yarn module cache
41-
uses: actions/cache@v3
53+
uses: actions/cache@v4
4254
with:
4355
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
4456
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
4557
restore-keys: |
4658
${{ runner.os }}-yarn-
59+
4760
- name: Download Yarn dependencies
4861
run: make js.deps
62+
4963
- name: Initialize Hugo binary cache
5064
id: cache-hugo
51-
uses: actions/cache@v3
65+
uses: actions/cache@v4
5266
with:
5367
path: hugo.linux
5468
key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.sum') }}
5569
restore-keys: |
5670
${{ runner.os }}-hugo-
71+
5772
- name: Build Hugo binary
5873
if: steps.cache-hugo.outputs.cache-hit != 'true'
5974
run: make hugo.linux
75+
6076
- name: Build docs
6177
run: make build.public
6278
env:
@@ -71,14 +87,35 @@ jobs:
7187
HUGO_PARAMS_SEARCH_APIKEY: ${{ secrets.HUGO_PARAMS_SEARCH_APIKEY }}
7288
HUGO_PARAMS_SEARCH_ENABLED: true
7389
HUGO_PARAMS_SEARCH_INDEX: thethingsstack
90+
91+
- name: Validate build output
92+
run: |
93+
if [ ! -d "public" ]; then
94+
echo "Error: Build output directory 'public' not found"
95+
exit 1
96+
fi
97+
7498
- name: Deploy documentation to Github pages
75-
uses: JamesIves/github-pages-deploy-action@releases/v4
99+
uses: JamesIves/github-pages-deploy-action@v4
76100
with:
77-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78-
BRANCH: gh-pages
79-
FOLDER: public
101+
token: ${{ secrets.GITHUB_TOKEN }}
102+
branch: gh-pages
103+
folder: public
104+
80105
- name: Make gateways.csv
81106
run: make gateways.csv
107+
continue-on-error: true
108+
82109
- name: Sync gateways.csv to airtable
110+
if: success() || failure()
83111
run: |
84-
curl -X POST ${{ secrets.AIRTABLE_GATEWAYS_API_ENDPOINT }} -H "Authorization: Bearer ${{ secrets.AIRTABLE_GATEWAYS_API_KEY }}" -H "Content-Type: text/csv" --data-binary "@gateways.csv"
112+
if [ ! -f gateways.csv ]; then
113+
echo "Warning: gateways.csv not found, skipping sync"
114+
exit 0
115+
fi
116+
curl -f -X POST ${{ secrets.AIRTABLE_GATEWAYS_API_ENDPOINT }} \
117+
-H "Authorization: Bearer ${{ secrets.AIRTABLE_GATEWAYS_API_KEY }}" \
118+
-H "Content-Type: text/csv" \
119+
--data-binary "@gateways.csv" \
120+
--fail-with-body
121+
continue-on-error: true

0 commit comments

Comments
 (0)