|
5 | 5 | merge_group:
|
6 | 6 | pull_request:
|
7 | 7 |
|
| 8 | +env: |
| 9 | + CHANGED_FILES: |
| 10 | + PR_NUM: ${{ github.event.issue.number }} |
| 11 | + |
| 12 | + USER_NAME: opentelemetrybot |
| 13 | + |
8 | 14 | jobs:
|
9 | 15 | build-and-check-links:
|
10 | 16 | name: BUILD and CHECK LINKS
|
@@ -43,29 +49,41 @@ jobs:
|
43 | 49 | echo "submodule(s); or undo the submodule update(s) if it happened by mistake."
|
44 | 50 | npm run _diff:fail
|
45 | 51 |
|
46 |
| - - run: npm run log:check:links |
| 52 | + - run: | |
| 53 | + npm run log:check:links |
| 54 | + CHANGED_FILES=$(git status --porcelain) |
| 55 | + echo "CHANGED_FILES=$CHANGED_FILES" >> "$GITHUB_ENV" |
47 | 56 | continue-on-error: true
|
48 | 57 |
|
49 | 58 | - name: Push changes if any, and fail check
|
| 59 | + if: ${{ env.CHANGED_FILES }} |
50 | 60 | run: |
|
51 |
| - if [[ $(git status --porcelain) ]]; then |
52 |
| - echo "Changes detected in the refcache etc:" |
53 |
| - git status --short |
54 |
| -
|
55 |
| - echo "\nPushing changes to PR." |
56 |
| - git config --local user.email "$USER_EMAIL" |
57 |
| - git config --local user.name "$USER_NAME" |
58 |
| - git add -A |
59 |
| - git commit -m "Updates from build-and-check-links workflow" |
60 |
| - git push |
61 |
| -
|
62 |
| - echo "Failing workflow so that changes can be reviewed, and checks rerun." |
63 |
| - exit 1 |
64 |
| - fi |
| 61 | + echo "Changes detected in the refcache etc:" |
| 62 | + git status --short |
| 63 | +
|
| 64 | + gh pr checkout $PR_NUM -b "pr-check-links-${RANDOM}" |
| 65 | + git branch -v |
| 66 | +
|
| 67 | + git config --local user.email "$USER_EMAIL" |
| 68 | + git config --local user.name "$USER_NAME" |
| 69 | + git add -A |
| 70 | + git commit -m "Updates from build-and-check-links workflow" |
| 71 | +
|
| 72 | + echo "\nPushing changes to PR." |
| 73 | + current_branch=$(git rev-parse --abbrev-ref HEAD) |
| 74 | + echo current_branch=$current_branch |
| 75 | + # gh pr checkout sets some git configs that we can use to make sure |
| 76 | + # we push to the right repo & to the right branch |
| 77 | + remote_repo=$(git config --get branch.${current_branch}.remote) |
| 78 | + echo remote_repo=$remote_repo |
| 79 | + remote_branch=$(git config --get branch.${current_branch}.merge) |
| 80 | + echo remote_branch=$remote_branch |
| 81 | + git push ${remote_repo} HEAD:${remote_branch} |
| 82 | +
|
| 83 | + echo "Failing workflow so that changes can be reviewed, and checks rerun." |
| 84 | + exit 1 |
65 | 85 | env:
|
66 | 86 | GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
|
67 |
| - |
68 |
| - USER_NAME: opentelemetrybot |
69 | 87 |
|
70 | 88 | - uses: actions/upload-artifact@v4
|
71 | 89 | with:
|
|
0 commit comments