forked from moby/buildkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Add workflow automation for maintaining patched fork #14
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
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9e3ef17
Consolidate documentation into single DEPLOYMENT.md
adityamaru 2da592c
Simplify to rebase-based workflow for patch management
adityamaru 24413f6
Remove FORK_WORKFLOW.md - consolidated into DEPLOYMENT.md
adityamaru 008d487
Fix yamllint errors: add newlines at end of workflow files
adityamaru 798bc75
Fix newline handling in patch messages
adityamaru 1ec4dcd
Fix build: Create bin directory before building binaries
adityamaru 78ccdff
Fix YAML syntax and git fetch issues in release workflow
adityamaru 485be4f
Add error checking for critical git push operations
adityamaru 8e1b7b0
Add required permissions to GitHub Actions workflows
adityamaru 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,111 @@ | ||
| name: Rebase on Upstream | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
| # Run weekly on Mondays at 9am UTC | ||
| - cron: '0 9 * * 1' | ||
|
|
||
| jobs: | ||
| rebase: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Setup git | ||
| run: | | ||
| git config user.name "GitHub Actions" | ||
| git config user.email "actions@github.com" | ||
|
|
||
| - name: Add upstream remote | ||
| run: | | ||
| git remote add upstream https://github.com/moby/buildkit.git || true | ||
| git fetch upstream master | ||
| git fetch origin master | ||
|
|
||
| - name: Rebase master on upstream | ||
| id: rebase | ||
| run: | | ||
| git checkout master | ||
|
|
||
| # Count our patches before rebase | ||
| BEFORE_COUNT=$(git rev-list upstream/master..HEAD --count) | ||
| echo "Patches before rebase: $BEFORE_COUNT" | ||
|
|
||
| # Perform rebase | ||
| if git rebase upstream/master; then | ||
| echo "✅ Rebase successful" | ||
|
|
||
| # Count our patches after rebase | ||
| AFTER_COUNT=$(git rev-list upstream/master..HEAD --count) | ||
| echo "Patches after rebase: $AFTER_COUNT" | ||
|
|
||
| # Check what changed | ||
| if [ "$BEFORE_COUNT" -ne "$AFTER_COUNT" ]; then | ||
| echo "" | ||
| echo "🎉 Patch count changed from $BEFORE_COUNT to $AFTER_COUNT" | ||
| echo "This likely means some of your patches were merged upstream!" | ||
| fi | ||
|
|
||
| # Push the rebased master | ||
| if ! git push origin master --force-with-lease; then | ||
| echo "❌ Rebase succeeded locally but failed to push to remote" | ||
| echo "" | ||
| echo "To push manually:" | ||
| echo " git push origin master --force-with-lease" | ||
| echo "" | ||
| echo "rebase_status=failed" >> $GITHUB_OUTPUT | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "✅ Successfully pushed rebased master to origin" | ||
| echo "rebase_status=success" >> $GITHUB_OUTPUT | ||
| echo "patch_count=$AFTER_COUNT" >> $GITHUB_OUTPUT | ||
cursor[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| else | ||
| echo "❌ Rebase failed - manual intervention required" | ||
| echo "" | ||
| echo "To resolve manually:" | ||
| echo "1. git checkout master" | ||
| echo "2. git rebase upstream/master" | ||
| echo "3. Resolve conflicts" | ||
| echo "4. git push origin master --force-with-lease" | ||
|
|
||
| echo "rebase_status=failed" >> $GITHUB_OUTPUT | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Create issue on failure | ||
| if: failure() | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| await github.rest.issues.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: 'Manual rebase required: conflicts with upstream', | ||
| body: `The automated rebase on upstream has failed due to conflicts. | ||
|
|
||
| ## Action Required | ||
|
|
||
| Please manually rebase the master branch: | ||
|
|
||
| \`\`\`bash | ||
| git checkout master | ||
| git fetch upstream | ||
| git rebase upstream/master | ||
| # Resolve any conflicts | ||
| git push origin master --force-with-lease | ||
| \`\`\` | ||
|
|
||
| ## Workflow Run | ||
|
|
||
| [View failed workflow run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) | ||
|
|
||
| --- | ||
| *This issue was automatically created by the rebase workflow.*`, | ||
| labels: ['upstream-sync', 'needs-attention'] | ||
| }); | ||
Oops, something went wrong.
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.