55 types : [ bump-dependency ]
66
77jobs :
8- get-label :
9- name : Get Label
10- outputs :
11- label : ${{ steps.get-label.outputs.label }}
8+ sanitize-payload :
9+ name : Sanitize Payload
1210 runs-on : ubuntu-22.04
11+ outputs :
12+ label : ${{ steps.sanitize.outputs.label }}
13+ safe_module : ${{ steps.sanitize.outputs.safe_module }}
14+ safe_head : ${{ steps.sanitize.outputs.safe_head }}
15+ safe_assignee:${{ steps.sanitize.outputs.safe_assignee }}
16+ safe_email : ${{ steps.sanitize.outputs.safe_email }}
17+ safe_branch : ${{ steps.sanitize.outputs.safe_branch }}
18+ safe_short : ${{ steps.sanitize.outputs.safe_short }}
1319 steps :
14- - name : Get Label (allow-listed dependencies only)
15- id : get-label
20+ - uses : actions/checkout@v4
21+ - name : Validate & Sanitize Payload (script)
22+ id : sanitize
1623 env :
17- REPO : ${{ github.event.client_payload.dependency }}
18- run : |
19- set -euo pipefail
20- IFS=$'\n\t'
21-
22- # allow-list: only 'vitess' at present
23- case "${REPO:-}" in
24- vitess)
25- echo "label=vitess-bump" >> "$GITHUB_OUTPUT"
26- ;;
27- *)
28- echo "Dependency '${REPO:-}' is unsupported"
29- exit 1
30- ;;
31- esac
24+ RAW_DEP : ${{ github.event.client_payload.dependency }}
25+ RAW_SHA : ${{ github.event.client_payload.head_commit_sha }}
26+ RAW_USER : ${{ github.event.client_payload.assignee }}
27+ RAW_MAIL : ${{ github.event.client_payload.assignee_email }}
28+ run : bash .github/workflows/scripts/sanitize_payload.sh
3229
3330 stale-bump-prs :
3431 name : Retrieving Stale Bump PRs
35- needs : get-label
32+ needs : sanitize-payload
3633 outputs :
3734 stale-pulls : ${{ steps.get-stale-prs.outputs.open-pulls }}
3835 runs-on : ubuntu-22.04
4138 id : get-stale-prs
4239 uses : actions/github-script@v7
4340 env :
44- LABEL : ${{ needs.get-label .outputs.label }}
41+ LABEL : ${{ needs.sanitize-payload .outputs.label }}
4542 with :
4643 debug : true
4744 github-token : ${{ secrets.REPO_ACCESS_TOKEN }}
9188 }
9289
9390 open-bump-pr :
94- needs : [get-label , stale-bump-prs]
91+ needs : [sanitize-payload , stale-bump-prs]
9592 name : Open Bump PR
9693 runs-on : ubuntu-22.04
9794 outputs :
@@ -106,70 +103,10 @@ jobs:
106103 with :
107104 go-version-file : go.mod
108105
109- - name : Validate & Sanitize Payload
110- id : sanitize
111- env :
112- RAW_DEP : ${{ github.event.client_payload.dependency }}
113- RAW_SHA : ${{ github.event.client_payload.head_commit_sha }}
114- RAW_USER : ${{ github.event.client_payload.assignee }}
115- RAW_MAIL : ${{ github.event.client_payload.assignee_email }}
116- run : |
117- set -euo pipefail
118- IFS=$'\n\t'
119-
120- # --- Validate dependency via allow-list and map to module path
121- case "${RAW_DEP:-}" in
122- vitess)
123- MODULE='github.com/dolthub/vitess'
124- ;;
125- *)
126- echo "Unsupported dependency '${RAW_DEP:-}'"
127- exit 1
128- ;;
129- esac
130-
131- # --- Validate head SHA/tag (conservative)
132- # allow only hex SHAs or safe tag-ish: letters, digits, dot, dash, underscore, plus
133- if [ -z "${RAW_SHA:-}" ] || ! printf '%s' "$RAW_SHA" | grep -qE '^[A-Za-z0-9._+-]+$'; then
134- echo "Invalid head_commit_sha"
135- exit 1
136- fi
137-
138- # Keep a short 8-char form if it's a hex SHA; otherwise keep original (already validated)
139- if printf '%s' "$RAW_SHA" | grep -qiE '^[0-9a-f]{40}$'; then
140- SHORT_SHA="${RAW_SHA:0:8}"
141- else
142- # derive a short-ish safe token
143- SHORT_SHA="$(printf '%s' "$RAW_SHA" | tr -cd 'A-Za-z0-9._+-' | cut -c1-12)"
144- fi
145-
146- # --- Validate assignee username (GitHub-compatible subset)
147- if [ -z "${RAW_USER:-}" ] || ! printf '%s' "$RAW_USER" | grep -qE '^[A-Za-z0-9-]{1,39}$'; then
148- echo "Invalid assignee username"
149- exit 1
150- fi
151-
152- # --- Validate email; if invalid, fall back to GitHub noreply
153- if [ -n "${RAW_MAIL:-}" ] && printf '%s' "$RAW_MAIL" | grep -qE '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$'; then
154- SAFE_EMAIL="$RAW_MAIL"
155- else
156- SAFE_EMAIL="${RAW_USER}[email protected] " 157- fi
158-
159- # --- Build a safe branch name: <assignee>-<short>
160- BRANCH_NAME="$(printf '%s-%s' "$RAW_USER" "$SHORT_SHA" | tr -cd 'A-Za-z0-9._-')"
161-
162- # Export for later steps
163- {
164- echo "SAFE_MODULE=$MODULE"
165- echo "SAFE_HEAD=$RAW_SHA"
166- echo "SAFE_ASSIGNEE=$RAW_USER"
167- echo "SAFE_EMAIL=$SAFE_EMAIL"
168- echo "SAFE_BRANCH=$BRANCH_NAME"
169- echo "SAFE_SHORT=$SHORT_SHA"
170- } >> "$GITHUB_ENV"
171-
172106 - name : Bump dependency (safe)
107+ env :
108+ SAFE_MODULE : ${{ needs.sanitize-payload.outputs.safe_module }}
109+ SAFE_HEAD : ${{ needs.sanitize-payload.outputs.safe_head }}
173110 run : |
174111 set -euo pipefail
175112 IFS=$'\n\t'
@@ -179,7 +116,7 @@ jobs:
179116 - name : Get Assignee and Reviewer (safe)
180117 id : get_reviewer
181118 env :
182- ASSIGNEE : ${{ env.SAFE_ASSIGNEE }}
119+ ASSIGNEE : ${{ needs.sanitize-payload.outputs.safe_assignee }}
183120 run : |
184121 set -euo pipefail
185122 if [ "${ASSIGNEE}" = "zachmu" ]; then
@@ -190,18 +127,18 @@ jobs:
190127
191128 - name : Create and Push new branch (safe)
192129 env :
193- GIT_USER : ${{ env.SAFE_ASSIGNEE }}
194- GIT_MAIL : ${{ env.SAFE_EMAIL }}
195- BRANCH : ${{ env.SAFE_BRANCH }}
196- COMMIT_BY : ${{ env.SAFE_ASSIGNEE }}
130+ GIT_USER : ${{ needs.sanitize-payload.outputs.safe_assignee }}
131+ GIT_MAIL : ${{ needs.sanitize-payload.outputs.safe_email }}
132+ BRANCH : ${{ needs.sanitize-payload.outputs.safe_branch }}
133+ COMMIT_BY : ${{ needs.sanitize-payload.outputs.safe_assignee }}
197134 run : |
198135 set -euo pipefail
199136 IFS=$'\n\t'
200137
201138 git config --global user.name "${GIT_USER}"
202139 git config --global user.email "${GIT_MAIL}"
203140
204- git checkout -b "${BRANCH}"
141+ git checkout -b -- "${BRANCH}"
205142 git add .
206143
207144 # Commit message uses sanitized assignee only
@@ -212,14 +149,14 @@ jobs:
212149 uses : repo-sync/pull-request@v2
213150 id : latest-pr
214151 with :
215- source_branch : ${{ env.SAFE_BRANCH }}
152+ source_branch : ${{ needs.sanitize-payload.outputs.safe_branch }}
216153 destination_branch : " main"
217154 github_token : ${{ secrets.REPO_ACCESS_TOKEN }}
218- pr_title : " [auto-bump] [no-release-notes] dependency by ${{ env.SAFE_ASSIGNEE }}"
155+ pr_title : " [auto-bump] [no-release-notes] dependency by ${{ needs.sanitize-payload.outputs.safe_assignee }}"
219156 pr_template : " .github/markdown-templates/dep-bump.md"
220157 pr_reviewer : ${{ steps.get_reviewer.outputs.reviewer }}
221- pr_assignee : ${{ env.SAFE_ASSIGNEE }}
222- pr_label : ${{ needs.get-label .outputs.label }}
158+ pr_assignee : ${{ needs.sanitize-payload.outputs.safe_assignee }}
159+ pr_label : ${{ needs.sanitize-payload .outputs.label }}
223160
224161 comment-on-stale-prs :
225162 needs : [open-bump-pr, stale-bump-prs]
0 commit comments