Skip to content

Merge pull request #3783 from Elutrixx/Statistic-Report-Improvements-… #17

Merge pull request #3783 from Elutrixx/Statistic-Report-Improvements-…

Merge pull request #3783 from Elutrixx/Statistic-Report-Improvements-… #17

name: Sync develop to importer-rework
on:
push:
branches: [develop]
permissions:
contents: write
pull-requests: write
jobs:
sync-branches:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Ensure "automation" label exists
run: |
gh label create automation \
--color "0e8a16" \
--description "Automatically created for syncing branches" \
--force
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute ahead/behind
id: ab
run: |
git fetch origin develop importer-rework
read behind ahead < <(git rev-list --left-right --count origin/importer-rework...origin/develop)
echo "ahead=$ahead" >> $GITHUB_OUTPUT
echo "behind=$behind" >> $GITHUB_OUTPUT
# rev-list separates counts with a TAB. :contentReference[oaicite:2]{index=2}
- name: Push sync branch (mirror develop)
if: steps.ab.outputs.ahead != '0'
run: |
BR=bot/sync-develop-into-importer-rework
git checkout -B "$BR" origin/develop
git push -f origin "HEAD:$BR"
- name: Check for existing PR (sync branch → importer-rework)
id: pr_check
if: steps.ab.outputs.ahead != '0'
run: |
existing_pr=$(gh pr list \
--base importer-rework \
--head bot/sync-develop-into-importer-rework \
--state open \
--json number \
--jq '.[0].number // empty')
echo "existing_pr=$existing_pr" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create PR from sync branch to importer-rework
if: steps.ab.outputs.ahead != '0' && steps.pr_check.outputs.existing_pr == ''
run: |
gh pr create \
--base importer-rework \
--head bot/sync-develop-into-importer-rework \
--title "Sync develop → importer-rework" \
--body "Auto-sync from \`develop\` via sync branch." \
--label automation
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# OPTIONAL: Automatically merge the PR if all checks pass
# - name: Auto-merge PR
# if: steps.pr_check.outputs.existing_pr != ''
# run: |
# gh pr merge "${{ steps.pr_check.outputs.existing_pr }}" --merge --admin
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}