Skip to content

Commit 3f8a625

Browse files
authored
fix(monitoring): fix job step on git push (#2751)
Signed-off-by: wuhuizuo <[email protected]> Signed-off-by: wuhuizuo <[email protected]>
1 parent c343f74 commit 3f8a625

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

prow-jobs/pingcap-monitoring-periodics.yaml

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ periodics:
2626
- name: github-token
2727
mountPath: /etc/github
2828
readOnly: true
29-
args:
29+
args: &args
3030
- |
31+
printenv
3132
go run ./cmd/monitoring.go --tag=$TARGET --config monitoring.yaml
3233
git add monitor-snapshot/$TARGET
33-
if git diff --cached --exit-code; then
34+
if git diff --exit-code --name-status; then
3435
echo "🤷 No changes happened."
3536
exit 0
3637
fi
@@ -56,7 +57,8 @@ periodics:
5657
git checkout -b "$head_branch"
5758
commit_msg="chore(monitor-snapshot/master): update files from upstreams"
5859
git commit -m "$commit_msg"
59-
git push origin "$head_branch"
60+
git remote -v
61+
git push --set-upstream origin "$head_branch"
6062
6163
# create pull request
6264
cat <<EOF > pr_body.txt
@@ -97,46 +99,7 @@ periodics:
9799
- name: github-token
98100
mountPath: /etc/github
99101
readOnly: true
100-
args:
101-
- |
102-
go run ./cmd/monitoring.go --tag=$TARGET --config monitoring.yaml
103-
git add monitor-snapshot/$TARGET
104-
if git diff --cached --exit-code; then
105-
echo "🤷 No changes happened."
106-
exit 0
107-
fi
108-
109-
git config user.email "[email protected]"
110-
git config user.name "ti-chi-bot"
111-
112-
# install `gh` tool
113-
type -p curl >/dev/null || ( apt update && apt install curl -y)
114-
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
115-
&& chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
116-
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
117-
&& apt update \
118-
&& apt install gh -y
119-
120-
# login and setup git
121-
gh auth login --with-token < /etc/github/token
122-
gh auth setup-git
123-
124-
# commit and push the changes.
125-
head_branch="fix/${TARGET}/update-snapshot-files"
126-
git checkout -b "$head_branch"
127-
commit_msg="chore(monitor-snapshot/master): update files from upstreams"
128-
git commit -m "$commit_msg"
129-
git push origin "$head_branch"
130-
131-
# create pull request
132-
cat <<EOF > pr_body.txt
133-
Auto generated by bot periodics.
134-
EOF
135-
gh pr create \
136-
--base $TARGET \
137-
--head "$head_branch" \
138-
--fill \
139-
--body-file pr_body.txt
102+
args: *args
140103
volumes:
141104
- name: github-token
142105
secret:

0 commit comments

Comments
 (0)