-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] check-links: update code to push refcache etc
- Loading branch information
Showing
1 changed file
with
36 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,12 @@ on: | |
merge_group: | ||
pull_request: | ||
|
||
env: | ||
CHANGED_FILES: | ||
PR_NUM: ${{ github.event.issue.number }} | ||
USER_EMAIL: [email protected] | ||
USER_NAME: opentelemetrybot | ||
|
||
jobs: | ||
build-and-check-links: | ||
name: BUILD and CHECK LINKS | ||
|
@@ -43,29 +49,42 @@ jobs: | |
echo "submodule(s); or undo the submodule update(s) if it happened by mistake." | ||
npm run _diff:fail | ||
- run: npm run log:check:links | ||
- run: | | ||
npm run log:check:links | ||
CHANGED_FILES=$(git status --porcelain) | ||
echo "CHANGED_FILES=$CHANGED_FILES" >> "$GITHUB_ENV" | ||
continue-on-error: true | ||
- name: Push changes if any, and fail check | ||
if: ${{ env.CHANGED_FILES }} | ||
run: | | ||
if [[ $(git status --porcelain) ]]; then | ||
echo "Changes detected in the refcache etc:" | ||
git status --short | ||
echo "\nPushing changes to PR." | ||
git config --local user.email "$USER_EMAIL" | ||
git config --local user.name "$USER_NAME" | ||
git add -A | ||
git commit -m "Updates from build-and-check-links workflow" | ||
git push | ||
echo "Failing workflow so that changes can be reviewed, and checks rerun." | ||
exit 1 | ||
fi | ||
echo "Changes detected in the refcache etc:" | ||
git status --short | ||
gh pr checkout $PR_NUM -b "pr-check-links-${RANDOM}" | ||
git branch -v | ||
git config --local user.email "$USER_EMAIL" | ||
git config --local user.name "$USER_NAME" | ||
git add -A | ||
git commit -m "Updates from build-and-check-links workflow" | ||
echo "\nPushing changes to PR." | ||
current_branch=$(git rev-parse --abbrev-ref HEAD) | ||
echo current_branch=$current_branch | ||
# gh pr checkout sets some git configs that we can use to make sure | ||
# we push to the right repo & to the right branch | ||
remote_repo=$(git config --get branch.${current_branch}.remote) | ||
echo remote_repo=$remote_repo | ||
remote_branch=$(git config --get branch.${current_branch}.merge) | ||
echo remote_branch=$remote_branch | ||
git commit -m "Results from /fix:${PR_ACTION}" | ||
git push ${remote_repo} HEAD:${remote_branch} | ||
echo "Failing workflow so that changes can be reviewed, and checks rerun." | ||
exit 1 | ||
env: | ||
GH_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }} | ||
USER_EMAIL: [email protected] | ||
USER_NAME: opentelemetrybot | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
|