Repository navigation
110 lines (98 loc) · 3.66 KB
/
Copy pathpush-docs-release.yml
File metadata and controls
110 lines (98 loc) · 3.66 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# On a published release (or manual dispatch with a version), pushes
# cli.md and swagger.yml to `treeverse/docs-next-lakeFS`.
name: Push docs release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Tag to snapshot (e.g. v1.80.0). Defaults to the latest release tag."
required: false
type: string
is_latest:
description: "Mark this release as the current latest. Uncheck when pushing a patch snapshot for an older minor."
required: false
type: boolean
default: true
concurrency:
group: push-docs-release
cancel-in-progress: false
jobs:
push-snapshot:
runs-on: ubuntu-latest
steps:
- name: Resolve target tag
id: tag
run: |
set -eu
TAG="${{ github.event.release.tag_name || inputs.version }}"
if [ -z "$TAG" ]; then
echo "No release tag and no manual input. Aborting." >&2
exit 1
fi
# vMAJOR.MINOR.PATCH -> vMAJOR.MINOR
MINOR=$(echo "$TAG" | sed -E 's/^(v[0-9]+\.[0-9]+).*/\1/')
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "minor=$MINOR" >> "$GITHUB_OUTPUT"
- name: Resolve is-latest flag
id: flags
run: |
# release events always update LATEST; workflow_dispatch respects the input.
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ inputs.is_latest }}" == "false" ]]; then
echo "is_latest=false" >> "$GITHUB_OUTPUT"
else
echo "is_latest=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v6
with:
ref: ${{ steps.tag.outputs.tag }}
- uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Generate cli.md
run: go run cmd/lakectl/main.go docs > /tmp/cli.md
- name: Mint treeverse-ci-bot token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ vars.TREEVERSE_CI_BOT_CLIENT_ID }}
private-key: ${{ secrets.TREEVERSE_CI_BOT_PRIVATE_KEY }}
owner: treeverse
repositories: docs-next-lakeFS
- name: Checkout docs-next-lakeFS
uses: actions/checkout@v6
with:
repository: treeverse/docs-next-lakeFS
token: ${{ steps.app-token.outputs.token }}
path: docs-next
ref: main
- name: Stage snapshot
run: |
set -eu
target="docs-next/reference-versions/oss/${{ steps.tag.outputs.minor }}"
mkdir -p "$target"
cp /tmp/cli.md "$target/cli.md"
cp api/swagger.yml "$target/swagger.yml"
if [[ "${{ steps.flags.outputs.is_latest }}" == "true" ]]; then
echo "${{ steps.tag.outputs.minor }}" > "docs-next/reference-versions/oss/LATEST"
fi
- name: Commit and push
working-directory: docs-next
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
BOT: ${{ steps.app-token.outputs.app-slug }}[bot]
run: |
set -eu
bot_id=$(gh api "users/$BOT" --jq .id)
git config user.name "$BOT"
git config user.email "$bot_id+$BOT@users.noreply.github.com"
git add "reference-versions/oss/${{ steps.tag.outputs.minor }}/"
git add "reference-versions/oss/LATEST"
if git diff --cached --quiet; then
echo "No changes — snapshot already up to date."
exit 0
fi
git commit -m "snapshot: oss/${{ steps.tag.outputs.minor }} from lakeFS@${{ steps.tag.outputs.tag }}"
git push origin main