-
Notifications
You must be signed in to change notification settings - Fork 13
Port rebuild workflow
#1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+136
−0
Merged
Port rebuild workflow
#1417
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| name: Rebuild Action | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [labeled] | ||
| workflow_dispatch: | ||
|
|
||
| defaults: | ||
| run: | ||
| shell: bash | ||
|
|
||
| jobs: | ||
| rebuild: | ||
| name: Rebuild Action | ||
| runs-on: ubuntu-latest | ||
| if: github.event.label.name == 'Rebuild' || github.event_name == 'workflow_dispatch' | ||
|
|
||
| env: | ||
| HEAD_REF: ${{ github.event.pull_request.head.ref || github.event.ref }} | ||
| BASE_BRANCH: ${{ github.event.pull_request.base.ref || 'main' }} | ||
|
|
||
| permissions: | ||
| contents: write # needed to push rebuilt commit | ||
| pull-requests: write # needed to comment on the PR | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
|
mbg marked this conversation as resolved.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pin to v7 rather than v6? |
||
| with: | ||
| fetch-depth: 0 | ||
| ref: ${{ env.HEAD_REF }} | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 | ||
| with: | ||
| node-version: 24 | ||
| cache: 'npm' | ||
|
mbg marked this conversation as resolved.
|
||
|
|
||
| - name: Remove label | ||
| if: github.event_name == 'pull_request' | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| gh pr edit --repo github/codeql-variant-analysis-action "$PR_NUMBER" \ | ||
| --remove-label "Rebuild" | ||
|
mbg marked this conversation as resolved.
|
||
|
|
||
| - name: Configure git | ||
| run: | | ||
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
| git config --global user.name "github-actions[bot]" | ||
|
|
||
| - name: Merge in changes from base branch | ||
| id: merge | ||
| run: | | ||
| git fetch origin "$BASE_BRANCH" | ||
|
|
||
| # Allow merge conflicts in `dist`, since rebuilding should resolve them. | ||
| git merge "origin/$BASE_BRANCH" | ||
|
mbg marked this conversation as resolved.
|
||
| MERGE_RESULT=$? | ||
|
|
||
| if [ "$MERGE_RESULT" -eq 0 ]; then | ||
| echo "Merge succeeded cleanly." | ||
| elif [ "$MERGE_RESULT" -eq 1 ]; then | ||
| echo "Merge conflicts detected (exit code $MERGE_RESULT), continuing." | ||
| else | ||
| echo "git merge failed with unexpected exit code $MERGE_RESULT." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ "$MERGE_RESULT" -ne 0 ]; then | ||
| echo "merge-in-progress=true" >> $GITHUB_OUTPUT | ||
|
|
||
| # Check for merge conflicts outside of `dist`. Disable git diff's trailing whitespace check. | ||
| if git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^dist/'; then | ||
| echo "Merge conflicts were detected outside of the dist directory. Please resolve them manually." | ||
| git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^dist/' || true | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "No merge conflicts found outside the dist directory. We should be able to resolve all of" \ | ||
| "these by rebuilding the Action." | ||
| fi | ||
|
|
||
| - name: Compile TypeScript | ||
| run: | | ||
| npm ci | ||
| npm run lint-fix | ||
| npm run build | ||
|
|
||
| - name: "Merge in progress: Finish merge and push" | ||
| if: steps.merge.outputs.merge-in-progress == 'true' | ||
| run: | | ||
| echo "Finishing merge and pushing changes." | ||
| git add --all | ||
| git commit --no-edit | ||
| git push | ||
|
|
||
| - name: "No merge in progress: Check for changes and push" | ||
| if: steps.merge.outputs.merge-in-progress != 'true' | ||
| id: push | ||
| run: | | ||
| if [ ! -z "$(git status --porcelain)" ]; then | ||
| echo "Changes detected, committing and pushing." | ||
| git add --all | ||
| # If the merge originally had conflicts, finish the merge. | ||
| # Otherwise, just commit the changes. | ||
| if git rev-parse --verify MERGE_HEAD >/dev/null 2>&1; then | ||
| echo "In progress merge detected, finishing it up." | ||
| git commit --no-edit | ||
| else | ||
| echo "No in-progress merge detected, committing changes." | ||
| git commit -m "Rebuild" | ||
| fi | ||
| echo "Pushing changes" | ||
| git push | ||
| echo "changes=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "No changes detected, nothing to commit." | ||
| fi | ||
|
|
||
| - name: Notify about rebuild | ||
| if: >- | ||
| github.event_name == 'pull_request' && | ||
| ( | ||
| steps.merge.outputs.merge-in-progress == 'true' || | ||
| steps.push.outputs.changes == 'true' | ||
| ) | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| run: | | ||
| echo "Pushed a commit to rebuild the Action." \ | ||
| "Please mark the PR as ready for review to trigger PR checks." | | ||
| gh pr comment --body-file - --repo github/codeql-variant-analysis-action "$PR_NUMBER" | ||
| gh pr ready --undo --repo github/codeql-variant-analysis-action "$PR_NUMBER" | ||
|
mbg marked this conversation as resolved.
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.