Repository navigation
148 lines (131 loc) · 6.02 KB
/
Copy pathrelease_manifests.yml
File metadata and controls
148 lines (131 loc) · 6.02 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Regenerate distribution/kubernetes manifests from the published Helm chart and
# push them directly to master as the vectordotdev-bot. The direct push is
# authorized by the release freeze window and the temporary bot bypasses on the
# master rulesets. Release preparation opens this window and the "Unfreeze
# master" workflow closes it.
# The Helm chart release workflow dispatches this after publishing a new chart.
# This replaces the manual `cargo vdev build manifests` step from the release
# checklists.
name: Refresh Kubernetes manifests
on:
workflow_dispatch:
inputs:
chart_version:
description: "Chart version published by the Helm release, e.g. 0.62.0. Empty picks the latest published chart."
required: false
default: ""
type: string
permissions:
contents: read # Restrictive default
concurrency:
# Serialize manifest refreshes; a queued run picks up the newest chart anyway.
group: refresh-kubernetes-manifests
cancel-in-progress: false
jobs:
refresh-manifests:
name: Regenerate manifests and push to master
if: github.repository == 'vectordotdev/vector'
runs-on: ubuntu-24.04
timeout-minutes: 15
steps:
- name: Checkout master
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: master
fetch-depth: 0
persist-credentials: false
- name: Require active release freeze
uses: ./.github/actions/require-release-freeze
with: &release-bot
app-client-id: ${{ secrets.GH_APP_VECTORDOTDEV_BOT_CLIENT_ID }}
app-private-key: ${{ secrets.GH_APP_VECTORDOTDEV_BOT_APP_PRIVATE_KEY }}
freeze-ruleset-id: ${{ vars.RELEASE_FREEZE_RULESET_ID }}
bot-bypass-ruleset-ids: ${{ vars.RELEASE_FREEZE_BOT_BYPASS }}
- name: Set up manifest generation
uses: ./.github/actions/setup
with:
vdev: true
mold: false
- name: Install helm
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
with:
token: ${{ github.token }}
- name: Install yq
run: |
set -euo pipefail
sudo curl -sSL -o /usr/local/bin/yq \
https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
# helm.vector.dev is the published index; the generation script reads the
# chart from there, so the refreshed manifests always match production.
- name: Verify published chart version
id: chart
env:
EXPECTED_VERSION: ${{ inputs.chart_version }}
run: |
set -euo pipefail
published=$(curl -sSL https://helm.vector.dev/index.yaml \
| yq e '.entries.vector[0].version' -)
if [[ -n "$EXPECTED_VERSION" && "$published" != "$EXPECTED_VERSION" ]]; then
echo "helm.vector.dev latest chart is $published, expected $EXPECTED_VERSION." >&2
echo "The chart index may still be propagating; re-run this workflow shortly." >&2
exit 1
fi
echo "version=$published" >> "$GITHUB_OUTPUT"
- name: Generate manifests
env:
CHART_VERSION: ${{ steps.chart.outputs.version }}
run: make generate-kubernetes-manifests CHART_VERSION="$CHART_VERSION"
- name: Check for changes
id: changes
env:
CHART_VERSION: ${{ steps.chart.outputs.version }}
run: |
set -euo pipefail
# Stage everything the generation script touched so both modified and
# newly created manifest files are detected; git diff alone ignores
# untracked files.
git add -A -- distribution/kubernetes
if git diff --cached --quiet -- distribution/kubernetes; then
echo "Manifests already match chart $CHART_VERSION; nothing to do."
exit 0
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Create Vector bot token
if: steps.changes.outputs.changed == 'true'
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.GH_APP_VECTORDOTDEV_BOT_CLIENT_ID }}
private-key: ${{ secrets.GH_APP_VECTORDOTDEV_BOT_APP_PRIVATE_KEY }}
permission-contents: write
- name: Require active release freeze
if: steps.changes.outputs.changed == 'true'
uses: ./.github/actions/require-release-freeze
with: *release-bot
- name: Push manifests to master
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
CHART_VERSION: ${{ steps.chart.outputs.version }}
run: |
set -euo pipefail
# All remote git operations go through the token-authenticated URL. The
# checkout ran with persist-credentials: false, so origin has no credentials.
remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
master=$(git ls-remote "$remote" refs/heads/master)
master=${master%%$'\t'*}
[[ "$(git rev-parse origin/master)" == "$master" ]] || {
echo "master moved since checkout; re-run this workflow." >&2
exit 1
}
git config user.name "vectordotdev-bot[bot]"
git config user.email "vectordotdev-bot[bot]@users.noreply.github.com"
# Commit only the generated manifest changes staged by the Check for
# changes step; nothing else is committed.
git commit -m "chore(kubernetes): refresh manifests for chart ${CHART_VERSION}"
# Plain non-force push: if master raced ahead since the check above,
# the push is rejected rather than rewriting history. Re-run this
# workflow from the new master; never rebase, retry, or force-push.
git push "$remote" HEAD:refs/heads/master
echo "Pushed manifests commit $(git rev-parse HEAD) to master for chart ${CHART_VERSION}." >> "$GITHUB_STEP_SUMMARY"