-
Notifications
You must be signed in to change notification settings - Fork 1
Add workflow for automatic rebase. #16
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
Open
DaniilKl
wants to merge
10
commits into
master
Choose a base branch
from
add-rebase-script
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8bb75cf
.github: workflows: rebase.yml: add; scripts: rebase.sh: add
DaniilKl 58e44a1
Add CI/CD workflow and a script for triggering Woodpecker workflow via
DaniilKl 382f529
.github: workflows: qubes-dom0-packagev2.yml: add qubes-component-branch
DaniilKl 0de7bf6
README.md: delete "Used by" for qubes-dom0-packagev2
DaniilKl ed96075
Address review
DaniilKl 9501536
scripts: rebase.sh: add empty commits handling
DaniilKl 2d9d77c
scripts: rebase.sh: add a note about empty commits
DaniilKl 08b43ea
.github: workflows: update actions/checkout to v6
DaniilKl e51d845
scripts: rebase.sh: Address review
DaniilKl b70dcd6
.github: workflows: rebase.yml: add rebase-exit-code output, the return
DaniilKl 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
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
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,104 @@ | ||
| --- | ||
| name: Try rebasing on updated upstream, report in case of conflicts | ||
|
|
||
| on: | ||
| workflow_call: | ||
| secrets: | ||
| first-remote-token: | ||
| description: > | ||
| Personal access token for performing the following operations on the | ||
| downstream-repo: fetch the repository, create a branch, delete a | ||
| branch, create commits on a branch, push to a branch, open a PR, close | ||
| a PR, get list of PRs. | ||
| required: true | ||
| inputs: | ||
| downstream-repo: | ||
| description: > | ||
| <first_repo> parameter for the rebase.sh script. | ||
| required: true | ||
| type: string | ||
| downstream-branch: | ||
| description: > | ||
| <first_repo_branch> parameter for the rebase.sh script. | ||
| required: true | ||
| type: string | ||
| upstream-repo: | ||
| description: > | ||
| <second_repo> parameter for the rebase.sh script. | ||
| required: true | ||
| type: string | ||
| upstream-branch: | ||
| description: > | ||
| <second_repo_branch> parameter for the rebase.sh script. | ||
| required: true | ||
| type: string | ||
| commit-user-name: | ||
| description: > | ||
| NAME parameter for the --commit-user-name option of the rebase.sh | ||
| script. | ||
| required: true | ||
| type: string | ||
| commit-user-email: | ||
| description: > | ||
| EMAIL parameter for the --commit-user-email option of the rebase.sh | ||
| script. | ||
| required: true | ||
| type: string | ||
| cicd-trigger-resume: | ||
| description: > | ||
| MESSAGE parameter for the --cicd-trigger-resume option of the | ||
| rebase.sh script. | ||
| required: true | ||
| type: string | ||
| outputs: | ||
| rebase-exit-code: | ||
| description: > | ||
| Exit code returned by the rebase.sh script. See the script's --help | ||
| output for the meaning of each code. | ||
| value: ${{ jobs.rebase-attempt.outputs.rebase-exit-code }} | ||
|
|
||
| jobs: | ||
| rebase-attempt: | ||
| runs-on: ubuntu-latest | ||
| name: Try rebasing on updated upstream, report in case of conflicts | ||
| permissions: | ||
| # For creation/deletion/pushing to branches and creating PRs | ||
| contents: write | ||
| outputs: | ||
| rebase-exit-code: ${{ steps.rebase.outputs.exit-code }} | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| repository: TrenchBoot/.github | ||
| path: shared | ||
| ref: ${{ job.workflow_sha }} | ||
| - name: Run script for rebasing | ||
| id: rebase | ||
| env: | ||
| FIRST_REMOTE_TOKEN: ${{ secrets.first-remote-token }} | ||
| DOWNSTREAM_REPO: ${{ inputs.downstream-repo }} | ||
| DOWNSTREAM_BRANCH: ${{ inputs.downstream-branch }} | ||
| UPSTREAM_REPO: ${{ inputs.upstream-repo }} | ||
| UPSTREAM_BRANCH: ${{ inputs.upstream-branch }} | ||
| NAME: ${{ inputs.commit-user-name }} | ||
| EMAIL: ${{ inputs.commit-user-email }} | ||
| MESSAGE: ${{ inputs.cicd-trigger-resume }} | ||
| run: | | ||
| set +e | ||
| shared/scripts/rebase.sh --first-remote-token "$FIRST_REMOTE_TOKEN" \ | ||
| --commit-user-name "$NAME" \ | ||
| --commit-user-email "$EMAIL" \ | ||
| --cicd-trigger-resume "$MESSAGE" \ | ||
| "$DOWNSTREAM_REPO" \ | ||
| "$DOWNSTREAM_BRANCH" \ | ||
| "$UPSTREAM_REPO" \ | ||
| "$UPSTREAM_BRANCH" | ||
| rc=$? | ||
| echo "exit-code=${rc}" >> "$GITHUB_OUTPUT" | ||
| # The "No rebase needed" return code should be considered a success | ||
| # here, as we do not want to show that a job has failed in that case | ||
| # to avoid drawing attention of maintainers. | ||
| if [ "$rc" -eq "5" ]; then | ||
| exit "0" | ||
| fi | ||
| exit "${rc}" | ||
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,73 @@ | ||
| name: Trigger a Woodpecker CI/CD pipeline | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| api-url: | ||
| description: > | ||
| Base URL of the Woodpecker instance, e.g. https://ci.example.com. | ||
| --api-url parameter for the woodpecker-trigger.sh script. | ||
| required: true | ||
| type: string | ||
| owner: | ||
| description: > | ||
| Repository owner (user or organization). | ||
| --owner parameter for the woodpecker-trigger.sh script. | ||
| required: true | ||
| type: string | ||
| repo: | ||
| description: > | ||
| Repository name. | ||
| --repo parameter for the woodpecker-trigger.sh script. | ||
| required: true | ||
| type: string | ||
| ref: | ||
| description: > | ||
| Branch to trigger the pipeline on. | ||
| --ref parameter for the woodpecker-trigger.sh script. | ||
| required: false | ||
| type: string | ||
| default: 'main' | ||
| inputs: | ||
| description: > | ||
| Additional --input flags to pass to woodpecker-trigger.sh, e.g. | ||
| "--input KEY=VALUE --input KEY2=VALUE2". Keys must be valid shell | ||
| variable names (no hyphens). | ||
| required: false | ||
| type: string | ||
| default: '' | ||
| secrets: | ||
| woodpecker-token: | ||
| description: > | ||
| Woodpecker API token for triggering the pipeline. | ||
| --token parameter for the woodpecker-trigger.sh script. | ||
| required: true | ||
|
|
||
| jobs: | ||
| trigger-woodpecker: | ||
| runs-on: ubuntu-latest | ||
| name: Trigger a Woodpecker CI/CD pipeline | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| repository: TrenchBoot/.github | ||
| path: shared | ||
| ref: ${{ job.workflow_sha }} | ||
| - name: Trigger Woodpecker CI/CD pipeline | ||
| env: | ||
| WOODPECKER_TOKEN: ${{ secrets.woodpecker-token }} | ||
| WOODPECKER_API_URL: ${{ inputs.api-url }} | ||
| WOODPECKER_OWNER: ${{ inputs.owner }} | ||
| WOODPECKER_REPO: ${{ inputs.repo }} | ||
| WOODPECKER_REF: ${{ inputs.ref }} | ||
| WOODPECKER_INPUTS: ${{ inputs.inputs }} | ||
| run: | | ||
| shared/scripts/woodpecker-trigger.sh \ | ||
| --token "$WOODPECKER_TOKEN" \ | ||
| --api-url "$WOODPECKER_API_URL" \ | ||
| --owner "$WOODPECKER_OWNER" \ | ||
| --repo "$WOODPECKER_REPO" \ | ||
| --ref "$WOODPECKER_REF" \ | ||
| $WOODPECKER_INPUTS |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should deal with return code 5 (nothing to rebase). I don't think failing job (red x) would look good. I think in that case rest of the jobs should be skipped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO differentiating between a rebase success and nothing to rebase could be useful, so instead of modifying the script, I have modified the reusable workflow: b70dcd6 . But now I need to check the
rebase-exit-codein the calling workflows.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified all workflows that use this reusable workflow so far: