Skip to content

Commit

Permalink
Add auto-sync with celestia CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ImJeremyHe committed Dec 12, 2024
1 parent c6b3883 commit 4007b40
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/celestia-sync.yml
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."

0 comments on commit 4007b40

Please sign in to comment.