Skip to content

Commit 285697b

Browse files
committed
fix(ci): Make sure to checkout the PR branch before pushing the diff generated from the pre-commit hooks
Context: https://github.com/redhat-developer/rhdh-operator/actions/runs/17475391158/job/49670949036?pr=1584
1 parent c32497f commit 285697b

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

.github/workflows/pre-commit.yaml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
# see list of approvers in OWNERS file
2222
environment:
2323
${{ (github.event.pull_request.head.repo.full_name == github.repository ||
24-
contains(fromJSON('["coreydaley","gazarenkov","kadel","nickboldt","rm3l","kim-tsao","Fortune-Ndlovu","subhashkhileri","zdrapela","openshift-cherrypick-robot", "Fortune-Ndlovu", "subhashkhileri", "zdrapela"]'), github.event.pull_request.user.login)) && 'internal' || 'external' }}
24+
contains(fromJSON('["gazarenkov","kadel","nickboldt","rm3l","kim-tsao","Fortune-Ndlovu","subhashkhileri","zdrapela","openshift-cherrypick-robot"]'), github.event.pull_request.user.login)) && 'internal' || 'external' }}
2525
runs-on: ubuntu-latest
2626
steps:
2727
- name: approved
@@ -66,18 +66,22 @@ jobs:
6666
run: |
6767
echo "CHANGED=$(if git diff --quiet; then echo "false"; else echo "true"; fi)" >> $GITHUB_OUTPUT
6868
69-
- name: Commit any changes
69+
- name: Commit and push any manifest changes
7070
if: ${{ steps.diff-checker.outputs.CHANGED == 'true' }}
7171
run: |
72+
git remote add fork "https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git"
73+
git fetch fork ${{ github.event.pull_request.head.ref }}
74+
git checkout -B pr-branch fork/${{ github.event.pull_request.head.ref }}
75+
7276
git config user.name 'github-actions[bot]'
7377
git config user.email 'github-actions[bot]@users.noreply.github.com'
74-
git fetch --prune
75-
git pull --rebase --autostash
78+
7679
git add -A .
7780
git commit \
7881
-m "chore(pre-commit): Auto-fix hooks" \
7982
-m "Co-authored-by: $GITHUB_ACTOR <$GITHUB_ACTOR@users.noreply.github.com>"
80-
git push
83+
84+
git push fork pr-branch:${{ github.event.pull_request.head.ref }}
8185
8286
- name: Comment on PR if manifests were updated
8387
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8

0 commit comments

Comments
 (0)