Repository navigation
71 lines (62 loc) · 2.12 KB
/
Copy pathdocs-deploy.yml
File metadata and controls
71 lines (62 loc) · 2.12 KB
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
name: Publish docs
on:
push:
branches:
- "[0-9]+.[0-9]+.x"
paths:
- "docs/**"
release:
types:
- published
permissions:
contents: read
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Check whether this ref belongs to the latest release of its major version
id: check
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
if [ "$EVENT_NAME" = "release" ]; then
current="$RELEASE_TAG"
else
current="$REF_NAME"
fi
major="${current%%.*}"
latest_tag=$(gh release list \
--repo "$GITHUB_REPOSITORY" \
--exclude-drafts \
--exclude-pre-releases \
--limit 1000 \
--json tagName \
--jq '.[].tagName' \
| grep -E "^${major}\.[0-9]+\.[0-9]+$" \
| sort -V \
| tail -n1)
latest_branch="${latest_tag%.*}.x"
if [ "$EVENT_NAME" = "release" ]; then
expected="$latest_tag"
else
expected="$latest_branch"
fi
echo "latest release of ${major}.x: ${latest_tag:-none} (branch ${latest_branch}), current: ${current}"
if [ -n "$latest_tag" ] && [ "$current" = "$expected" ]; then
echo "deploy=true" >> "$GITHUB_OUTPUT"
else
echo "deploy=false" >> "$GITHUB_OUTPUT"
echo "Skipping docs deployment: ${current} is not the latest release of ${major}.x."
fi
- name: Trigger workflow in other repo
if: steps.check.outputs.deploy == 'true'
run: |
curl -L -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/repos/patchlevel/patchlevel.dev/actions/workflows/prod-deployment.yaml/dispatches \
-d '{"ref":"main"}'