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
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- if [ "$REPO" == "vitess" ]
20- then
21- echo "label=vitess-bump" >> $GITHUB_OUTPUT
22- else
23- echo "$REPO is unsupported"
24- exit 1
25- fi
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
2629
2730 stale-bump-prs :
2831 name : Retrieving Stale Bump PRs
29- needs : get-label
32+ needs : sanitize-payload
3033 outputs :
3134 stale-pulls : ${{ steps.get-stale-prs.outputs.open-pulls }}
3235 runs-on : ubuntu-22.04
3538 id : get-stale-prs
3639 uses : actions/github-script@v7
3740 env :
38- LABEL : ${{ needs.get-label .outputs.label }}
41+ LABEL : ${{ needs.sanitize-payload .outputs.label }}
3942 with :
4043 debug : true
4144 github-token : ${{ secrets.REPO_ACCESS_TOKEN }}
8588 }
8689
8790 open-bump-pr :
88- needs : [get-label , stale-bump-prs]
91+ needs : [sanitize-payload , stale-bump-prs]
8992 name : Open Bump PR
9093 runs-on : ubuntu-22.04
9194 outputs :
@@ -94,48 +97,66 @@ jobs:
9497 - uses : actions/checkout@v4
9598 with :
9699 token : ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
100+
97101 - name : Set up Go 1.x
98102 uses : actions/setup-go@v5
99103 with :
100104 go-version-file : go.mod
101- - name : Bump dependency
102- run : GOOS=linux go get github.com/dolthub/${{ github.event.client_payload.dependency }}@${{ github.event.client_payload.head_commit_sha }}
103- - name : Get Assignee and Reviewer
105+
106+ - name : Bump dependency (safe)
107+ env :
108+ SAFE_MODULE : ${{ needs.sanitize-payload.outputs.safe_module }}
109+ SAFE_HEAD : ${{ needs.sanitize-payload.outputs.safe_head }}
110+ run : |
111+ set -euo pipefail
112+ IFS=$'\n\t'
113+ echo "Installing ${SAFE_MODULE}@${SAFE_HEAD}"
114+ GOOS=linux go get "${SAFE_MODULE}@${SAFE_HEAD}"
115+
116+ - name : Get Assignee and Reviewer (safe)
104117 id : get_reviewer
118+ env :
119+ ASSIGNEE : ${{ needs.sanitize-payload.outputs.safe_assignee }}
105120 run : |
106- if [ "${{ github.event.client_payload.assignee }}" == "zachmu" ]
107- then
108- echo "reviewer=Hydrocharged" >> $GITHUB_OUTPUT
121+ set -euo pipefail
122+ if [ "${ASSIGNEE}" = "zachmu" ]; then
123+ echo "reviewer=Hydrocharged" >> " $GITHUB_OUTPUT"
109124 else
110- echo "reviewer=zachmu" >> $GITHUB_OUTPUT
125+ echo "reviewer=zachmu" >> " $GITHUB_OUTPUT"
111126 fi
112- - name : Get short hash
113- id : short-sha
114- run : |
115- commit= ${{ github.event.client_payload.head_commit_sha }}
116- short=${commit:0:8 }
117- echo "short=$short" >> $GITHUB_OUTPUT
118- - name : Create and Push new branch
127+
128+ - name : Create and Push new branch (safe)
129+ env :
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 }}
119134 run : |
120- git config --global --add user.name "${{ github.event.client_payload.assignee }}"
121- git config --global --add user.email "${{ github.event.client_payload.assignee_email }}"
122- branchname=${{ format('{0}-{1}', github.event.client_payload.assignee, steps.short-sha.outputs.short) }}
123- git checkout -b "$branchname"
135+ set -euo pipefail
136+ IFS=$'\n\t'
137+
138+ git config --global user.name "${GIT_USER}"
139+ git config --global user.email "${GIT_MAIL}"
140+
141+ git checkout -b -- "${BRANCH}"
124142 git add .
125- git commit -m "${{ format('[ga-bump-dep] Bump dependency in GMS by {0}', github.event.client_payload.assignee) }}"
126- git push origin "$branchname"
143+
144+ # Commit message uses sanitized assignee only
145+ git commit -m "[ga-bump-dep] Bump dependency in GMS by ${COMMIT_BY}"
146+ git push origin "${BRANCH}"
147+
127148 - name : pull-request
128149 uses : repo-sync/pull-request@v2
129150 id : latest-pr
130151 with :
131- source_branch : ${{ format('{0}-{1}', github.event.client_payload.assignee, steps.short-sha .outputs.short ) }}
152+ source_branch : ${{ needs.sanitize-payload .outputs.safe_branch }}
132153 destination_branch : " main"
133154 github_token : ${{ secrets.REPO_ACCESS_TOKEN }}
134- pr_title : " [auto-bump] [no-release-notes] dependency by ${{ github.event.client_payload.assignee }}"
155+ pr_title : " [auto-bump] [no-release-notes] dependency by ${{ needs.sanitize-payload.outputs.safe_assignee }}"
135156 pr_template : " .github/markdown-templates/dep-bump.md"
136157 pr_reviewer : ${{ steps.get_reviewer.outputs.reviewer }}
137- pr_assignee : ${{ github.event.client_payload.assignee }}
138- pr_label : ${{ needs.get-label .outputs.label }}
158+ pr_assignee : ${{ needs.sanitize-payload.outputs.safe_assignee }}
159+ pr_label : ${{ needs.sanitize-payload .outputs.label }}
139160
140161 comment-on-stale-prs :
141162 needs : [open-bump-pr, stale-bump-prs]
0 commit comments