Repository navigation
ci: open a sync PR for each upstream desktop release #23
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 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
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,91 @@ | ||
| # Voltage fork only: opens a sync PR when block/buzz publishes a desktop | ||
| # release that main does not contain yet. Merge sync PRs with "Create a merge | ||
| # commit" so upstream commits keep their SHAs; see the upstream-fork-sync skill. | ||
| name: Upstream release sync | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 13 * * *" | ||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Upstream release tag, for example desktop-v0.5.28 (default: latest desktop release)" | ||
| required: false | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| concurrency: | ||
| group: voltage-upstream-sync | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| open-sync-pr: | ||
| name: Open sync PR | ||
| if: github.repository == 'voltagecloud/buzz' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| REPO: ${{ github.repository }} | ||
| UPSTREAM: block/buzz | ||
| INPUT_TAG: ${{ inputs.tag }} | ||
| steps: | ||
| - name: Open a sync PR for a new upstream release | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| tag="${INPUT_TAG:-}" | ||
| if [ -z "$tag" ]; then | ||
| tag=$(gh release list -R "$UPSTREAM" --exclude-drafts --exclude-pre-releases --limit 50 \ | ||
| --json tagName,publishedAt \ | ||
| --jq '[.[] | select(.tagName | startswith("desktop-v"))] | sort_by(.publishedAt) | last | .tagName // empty') | ||
| fi | ||
| if [ -z "$tag" ]; then | ||
| echo "No upstream desktop release found." | ||
| exit 0 | ||
| fi | ||
| if ! [[ "$tag" =~ ^desktop-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "::error::Unexpected tag format: $tag" | ||
| exit 1 | ||
| fi | ||
|
|
||
| sha=$(gh api "repos/$UPSTREAM/commits/$tag" --jq .sha) | ||
| status=$(gh api "repos/$REPO/compare/main...${UPSTREAM/\//:}:$tag" --jq .status) | ||
| if [ "$status" = "behind" ] || [ "$status" = "identical" ]; then | ||
| echo "main already contains $tag." | ||
| exit 0 | ||
| fi | ||
|
|
||
| branch="sync/$tag" | ||
| existing=$(gh pr list -R "$REPO" --head "$branch" --state all --json number --jq '.[0].number // empty') | ||
| if [ -n "$existing" ]; then | ||
| echo "Sync PR #$existing already exists for $tag." | ||
| exit 0 | ||
| fi | ||
|
|
||
| # The refs API points the branch at the upstream commit, which the | ||
| # fork network already stores. A git push of upstream workflow | ||
| # changes would need the workflows permission, which GITHUB_TOKEN | ||
| # cannot have. | ||
| if ! gh api "repos/$REPO/git/ref/heads/$branch" >/dev/null 2>&1; then | ||
| gh api -X POST "repos/$REPO/git/refs" -f ref="refs/heads/$branch" -f sha="$sha" >/dev/null | ||
| fi | ||
|
|
||
| body=$(cat <<EOF | ||
| Upstream \`$UPSTREAM\` published \`$tag\` (\`$sha\`). This PR brings that release into \`main\`. | ||
|
|
||
| ## Merge | ||
|
|
||
| - Merge with **Create a merge commit**. Do not squash or rebase: both rewrite upstream commits and make the next sync conflict. | ||
| - CI does not start for PRs that \`GITHUB_TOKEN\` opens. Close and reopen this PR to start CI. | ||
| - If GitHub reports conflicts, follow the \`upstream-fork-sync\` skill to resolve them in a signed merge commit. | ||
| - After the merge, rebase open stacked PRs onto \`main\`. | ||
|
|
||
| CodeRabbit skips this PR because its title contains "merge upstream". Review the conflict resolution, if any, and the CI results. | ||
| EOF | ||
| ) | ||
| gh pr create -R "$REPO" --base main --head "$branch" \ | ||
| --title "chore(sync): merge upstream $tag" --body "$body" | ||
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.