/
niceSOFT
/
python3-setuptools_scm
Обзор
Документация
Войти
/
niceSOFT
/
python3-setuptools_scm
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
.github/workflows/branch-sync.yml
108 строк
4 KB
dependabot[bot]
build(deps): bump the github-actions group across 1 directory with 4 updates
10 апр 2026, 21:23
Не верифицирован
10 апр 2026, 21:23
4742d69
Код
Авторство
О чём код?
name: Branch Synchronization # After a release completes on main, sync main back to develop # so develop stays up to date with release commits (changelog, tags, etc.) on: pull_request: types: [closed] branches: - main permissions: contents: write pull-requests: write jobs: sync-main-to-develop: # Only run when a release PR is merged to main (primary repo only — no sync PRs on forks) if: | github.repository == 'pypa/setuptools-scm' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') runs-on: ubuntu-latest steps: - name: Create PR main → develop uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 with: script: | const owner = context.repo.owner; const repo = context.repo.repo; // Check if develop branch exists try { await github.rest.repos.getBranch({ owner, repo, branch: 'develop' }); } catch (error) { if (error.status === 404) { console.log('develop branch does not exist, skipping'); return; } throw error; } // Check if main has commits that develop doesn't const { data: comparison } = await github.rest.repos.compareCommits({ owner, repo, base: 'develop', head: 'main' }); if (comparison.ahead_by === 0) { console.log('main has no new commits for develop, skipping'); return; } console.log(`main has ${comparison.ahead_by} commits not on develop`); // Check for existing sync PR const { data: existingPRs } = await github.rest.pulls.list({ owner, repo, state: 'open', head: `${owner}:main`, base: 'develop' }); if (existingPRs.length > 0) { console.log(`Sync PR already exists: #${existingPRs[0].number}`); return; } const pr = context.payload.pull_request; const body = [ '## Branch Synchronization', '', `Syncs release changes from \`main\` back to \`develop\` after merging ${pr.title}.`, '', 'This is an automated PR created by the branch-sync workflow.', 'Review and merge to keep `develop` up to date with `main`.' ].join('\n'); const { data: syncPR } = await github.rest.pulls.create({ owner, repo, title: `Sync: main → develop`, body: body, head: 'main', base: 'develop' }); console.log(`Created sync PR #${syncPR.number}`); await github.rest.issues.addLabels({ owner, repo, issue_number: syncPR.number, labels: ['sync'] }); // Try to enable auto-merge try { await github.graphql(` mutation($pullRequestId: ID!) { enablePullRequestAutoMerge(input: {pullRequestId: $pullRequestId, mergeMethod: MERGE}) { pullRequest { autoMergeRequest { enabledAt } } } } `, { pullRequestId: syncPR.node_id }); console.log('Auto-merge enabled'); } catch (error) { console.log('Could not enable auto-merge:', error.message); }