forked from OffchainLabs/nitro
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto-sync with celestia CI workflow
- Loading branch information
1 parent
c6b3883
commit 4007b40
Showing
1 changed file
with
78 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
name: Cherry-pick commits and open PR | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- integration | ||
types: | ||
- closed | ||
workflow_dispatch: | ||
|
||
jobs: | ||
cherry-pick-and-create-pr: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Fetch all branches | ||
run: git fetch --all | ||
|
||
- name: Ensure integration branch exists | ||
run: | | ||
if ! git show-ref --verify --quiet refs/remotes/origin/integration; then | ||
echo "Integration branch not found. Exiting."; | ||
exit 1; | ||
fi | ||
- name: Create new branch from integration | ||
run: | | ||
NEW_BRANCH="bot/celestia-sync" | ||
git checkout -b $NEW_BRANCH origin/integration | ||
echo "NEW_BRANCH=$NEW_BRANCH" >> $GITHUB_ENV | ||
- name: Push new branch to origin | ||
run: | | ||
git push --force origin $NEW_BRANCH | ||
- name: Check for existing PR to celestia-integration | ||
id: check-pr | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { data: pulls } = await github.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
base: 'celestia-integration', | ||
head: `${context.repo.owner}:${process.env.NEW_BRANCH}`, | ||
}); | ||
if (pulls.length > 0) { | ||
core.setOutput('pr_exists', 'true'); | ||
core.setOutput('pr_url', pulls[0].html_url); | ||
} else { | ||
core.setOutput('pr_exists', 'false'); | ||
} | ||
- name: Create Pull Request to celestia-integration | ||
if: steps.check-pr.outputs.pr_exists == 'false' | ||
uses: peter-evans/create-pull-request@v5 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ env.NEW_BRANCH }} | ||
base: celestia-integration | ||
title: "Cherry-pick commits from integration" | ||
body: | | ||
This PR cherry-picks all commits from the integration branch into the celestia-integration branch. | ||
- name: Log existing PR | ||
if: steps.check-pr.outputs.pr_exists == 'true' | ||
run: | | ||
echo "A PR already exists: ${{ steps.check-pr.outputs.pr_url }}. No new PR will be created." |