Skip to content

Commit 72b1416

Browse files
authored
GH Actions audit and cleanup; go bumps (#123)
1 parent 6536028 commit 72b1416

File tree

9 files changed

+167
-116
lines changed

9 files changed

+167
-116
lines changed

.github/workflows/docs_deploy.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,43 @@
11
name: Deploy Docs
2-
permissions:
3-
contents: write
42
on:
53
push:
64
tags:
75
- "[0-9]+.[0-9]+.[0-9]+"
86
workflow_dispatch:
97

8+
permissions: {} # future-proof, preemptively move permissions into jobs level
9+
1010
jobs:
1111
deploy:
1212
concurrency: ci-${{ github.ref }}
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-24.04
1414
env:
1515
HUGO_VERSION: 0.123.8
16+
permissions:
17+
# We deploy to GitHub Pages via push to gh-pages branch
18+
contents: write
19+
1620
steps:
17-
-
21+
-
1822
name: Install Hugo CLI
1923
run: |
2024
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
2125
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
22-
-
26+
-
2327
name: Install Dart Sass
2428
run: sudo snap install dart-sass
25-
-
29+
-
2630
name: Checkout
2731
uses: actions/checkout@v4
2832
with:
2933
submodules: recursive
3034
fetch-depth: 0
31-
-
35+
persist-credentials: true # for push to gh-pages branch
36+
-
3237
name: Install Node.js dependencies
3338
working-directory: ./docs
3439
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
35-
-
40+
-
3641
name: Build with Hugo
3742
working-directory: ./docs
3843
env:
@@ -42,8 +47,8 @@ jobs:
4247
hugo \
4348
--gc \
4449
--minify \
45-
--baseURL "https://docs.natster.io"
46-
-
50+
--baseURL "https://docs.natster.io"
51+
-
4752
name: Deploy Docs
4853
uses: JamesIves/github-pages-deploy-action@v4
4954
with:

.github/workflows/docs_pr.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,66 @@ on:
88
- synchronize
99
- closed
1010

11-
permissions: write-all
12-
1311
concurrency: preview-${{ github.ref }}
1412
defaults:
1513
run:
1614
shell: bash
1715

16+
permissions: {} # future-proof, preemptively move permissions into jobs level
17+
1818
jobs:
1919
deploy-preview:
20-
runs-on: ubuntu-20.04
20+
runs-on: ubuntu-24.04
2121
env:
2222
HUGO_VERSION: 0.123.8
23+
permissions:
24+
# the preview step writes to the gh-pages branch and pushes;
25+
# it updates deployments and leaves comments on issues
26+
contents: write
27+
deployments: write
28+
issues: write
29+
# TBD: might we also need `pages: write` for a new deploy?
30+
# I (pdp 2025-03) don't see that; rossjrw/pr-preview-action uses JamesIves/github-pages-deploy-action
31+
# under the covers and that's all git force-pushing of deployment branches.
32+
2333
steps:
24-
-
34+
-
2535
name: Install Hugo CLI
2636
run: |
2737
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
2838
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
29-
-
39+
-
3040
name: Install Dart Sass
3141
run: sudo snap install dart-sass
32-
-
42+
-
3343
name: Checkout
3444
uses: actions/checkout@v4
3545
with:
3646
submodules: recursive
3747
fetch-depth: 0
38-
-
48+
persist-credentials: true # for step 'preview'
49+
-
3950
name: Install Node.js dependencies
4051
working-directory: ./docs
4152
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
42-
-
53+
-
4354
name: Build with Hugo
44-
working-directory: ./docs
55+
id: build
4556
if: github.event.action != 'closed' # skip the build if the PR has been closed
57+
working-directory: ./docs
4658
env:
4759
HUGO_ENVIRONMENT: production
4860
HUGO_ENV: production
4961
run: |
5062
hugo \
5163
--gc \
5264
--minify \
53-
--baseURL "https://docs.natster.io/pr-preview/pr-${{ github.event.number }}"
54-
-
65+
--baseURL "https://docs.natster.io/pr-preview/pr-${{ github.event.number }}"
66+
-
5567
name: Deploy preview
68+
id: preview
69+
if: github.event.action != 'closed' # skip the build if the PR has been closed
5670
uses: rossjrw/pr-preview-action@v1
5771
with:
5872
source-dir: ./docs/public/
59-
custom-url: "docs.natster.io"
73+
pages-base-url: "docs.natster.io"

.github/workflows/release.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ on:
66
- "[0-9]+.[0-9]+.[0-9]+"
77
workflow_dispatch:
88

9-
permissions:
10-
contents: read
11-
pages: write
12-
id-token: write
9+
permissions: {} # future-proof, preemptively move permissions into jobs level
1310

1411
concurrency:
1512
group: "release"
@@ -22,23 +19,32 @@ jobs:
2219
concurrency:
2320
group: release-installer-${{ github.ref }}
2421
cancel-in-progress: false
22+
permissions:
23+
contents: read
24+
pages: write
25+
id-token: write
26+
2527
steps:
2628
-
2729
name: Checkout
2830
uses: actions/checkout@v4
2931
with:
3032
fetch-depth: 0
33+
persist-credentials: false
3134
-
3235
name: Set up Go
3336
uses: actions/setup-go@v4
3437
with:
35-
go-version: '1.22.0'
38+
go-version: '1.24.1'
39+
# Caching: we are making release artifacts, and unfortunately we need
40+
# to ensure that the cache is not poisonable.
41+
cache: false
3642
-
3743
name: Run GoReleaser
38-
uses: goreleaser/goreleaser-action@v5
44+
uses: goreleaser/goreleaser-action@v6
3945
with:
4046
distribution: goreleaser
41-
version: latest
47+
version: '~> v2'
4248
args: release --verbose --clean
4349
env:
4450
GITHUB_TOKEN: ${{ secrets.GHA_RELEASE }}

.github/workflows/ui.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ on:
33
pull_request:
44
branches:
55
- main
6+
7+
permissions: {}
8+
69
jobs:
10+
711
check-ui:
812
runs-on: ubuntu-latest
913
name: Check UI for edits
@@ -13,43 +17,53 @@ jobs:
1317
- uses: actions/checkout@v4
1418
with:
1519
fetch-depth: 0
16-
17-
- name: Get changes to UI directory
20+
persist-credentials: false
21+
- name: Determine if changes to UI directory
1822
id: ui-edited
19-
uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 ## @v42 reiified by pdp 2025-03-14 in repo compromised tags incident
20-
with:
21-
files: natster-io/**
23+
shell: bash
24+
run: |
25+
: "${GITHUB_BASE_REF:?missing GITHUB_BASE_REF on push, fixme}"
26+
changes="$(git diff-tree -r --name-only "origin/$GITHUB_BASE_REF" HEAD -- natster-io)"
27+
if [[ -n "$changes" ]]; then
28+
echo >> "$GITHUB_OUTPUT" "any_changed=true"
29+
else
30+
echo >> "$GITHUB_OUTPUT" "any_changed=false"
31+
fi
32+
2233
check-formatter:
2334
runs-on: ubuntu-latest
2435
name: Checks to see if UI code is formatted
2536
needs: check-ui
2637
if: needs.check-ui.outputs.status
2738
steps:
28-
-
39+
-
2940
uses: actions/checkout@v4
3041
with:
3142
fetch-depth: 0
32-
-
43+
persist-credentials: false
44+
-
3345
name: Install UI deps
3446
working-directory: ./natster-io
3547
run: |
3648
curl -fsSL https://get.pnpm.io/install.sh | SHELL=bash sh -
3749
~/.local/share/pnpm/pnpm install
38-
-
50+
-
3951
name: Check formatting
4052
working-directory: ./natster-io
4153
run: ~/.local/share/pnpm/pnpm run check-formatting
54+
4255
build-ui:
4356
runs-on: ubuntu-latest
4457
name: Builds UI if edits found
4558
needs: check-ui
4659
if: needs.check-ui.outputs.status
4760
steps:
48-
-
61+
-
4962
uses: actions/checkout@v4
5063
with:
5164
fetch-depth: 0
52-
-
65+
persist-credentials: false
66+
-
5367
name: Build ui
5468
working-directory: ./natster-io
5569
run: |
@@ -60,14 +74,14 @@ jobs:
6074
name: Set up Go
6175
uses: actions/setup-go@v4
6276
with:
63-
go-version: '1.22.0'
77+
go-version: '1.24.1'
6478
-
6579
name: Build server
6680
working-directory: ./natster-io/server
6781
run: |
6882
go build -tags netgo -ldflags '-extldflags "-static"' -o natster-ui-server
6983
go build -tags with_tailscale -o natster-ui-server-ts
70-
-
84+
-
7185
name: Archive server binaries
7286
uses: actions/upload-artifact@v4
7387
with:

.github/workflows/ui_prod.yml

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,44 @@ on:
44
tags:
55
- "[0-9]+.[0-9]+.[0-9]+"
66

7-
jobs:
8-
check-ui:
9-
runs-on: ubuntu-latest
10-
name: Check UI for edits
11-
outputs:
12-
status: ${{ steps.ui-edited.outputs.any_changed }}
13-
steps:
14-
- uses: actions/checkout@v4
15-
with:
16-
fetch-depth: 0
7+
# For tag pushes, we always build and deploy
178

18-
- name: Get changes to UI directory
19-
id: ui-edited
20-
uses: tj-actions/changed-files@aa08304bd477b800d468db44fe10f6c61f7f7b11 ## @v42 reiified by pdp 2025-03-14 in repo compromised tags incident
21-
with:
22-
files: natster-io/**
9+
permissions: {}
2310

11+
jobs:
2412
build-ui:
2513
runs-on: ubuntu-latest
2614
name: Builds UI if edits found
27-
needs: check-ui
28-
if: needs.check-ui.outputs.status
15+
permissions:
16+
contents: read # clone repo
17+
actions: write # upload artifacts
2918
steps:
30-
-
19+
-
3120
uses: actions/checkout@v4
3221
with:
3322
fetch-depth: 0
34-
-
23+
persist-credentials: false
24+
-
3525
name: Build ui
3626
working-directory: ./natster-io
3727
run: |
38-
curl -fsSL https://get.pnpm.io/install.sh | SHELL=bash sh -
28+
curl -fsSL https://get.pnpm.io/install.sh | SHELL=bash bash -
3929
~/.local/share/pnpm/pnpm install
4030
~/.local/share/pnpm/pnpm build-only --outDir server/dist
4131
-
4232
name: Set up Go
43-
uses: actions/setup-go@v4
33+
uses: actions/setup-go@v5
4434
with:
45-
go-version: '1.22.0'
35+
go-version: '1.24.1'
36+
# Caching: we are making release artifacts, and unfortunately we need
37+
# to ensure that the cache is not poisonable.
38+
cache: false
4639
-
4740
name: Build server
4841
working-directory: ./natster-io/server
4942
run: |
5043
go build -o natster-ui-server
51-
-
44+
-
5245
name: Archive server binaries
5346
uses: actions/upload-artifact@v4
5447
with:
@@ -64,19 +57,23 @@ jobs:
6457
environment:
6558
name: Prod
6659
url: https://natster.io
60+
permissions:
61+
actions: read # download artifacts
62+
id-token: write # OIDC exchange for tailscale
6763
steps:
6864
-
6965
name: Download server artifact
7066
uses: actions/download-artifact@v4
7167
with:
7268
name: web_server
73-
-
69+
-
7470
name: Tailscale
75-
uses: tailscale/github-action@v2
71+
uses: tailscale/github-action@v3
7672
with:
7773
oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
7874
oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
7975
tags: tag:natster
76+
# No SSH keys needed for SSH below, it's using Tailscale connection ambient identity
8077
-
8178
name: Stop Prod Server
8279
run: |
@@ -89,4 +86,4 @@ jobs:
8986
name: Restart Prod Server
9087
run: |
9188
ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" root@natster-ui.pig-bee.ts.net systemctl start natster-ui-prod.service
92-
89+

0 commit comments

Comments
 (0)