-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
58 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,58 @@ | ||
name: Sync Release with Main | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: # allows manual triggers | ||
|
||
jobs: | ||
update-release-branch: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 # Fetch the full history | ||
|
||
- name: Set up Git | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
- name: Fetch all branches | ||
run: git fetch --all | ||
|
||
- name: Check for differences between main and release | ||
id: diff-check | ||
run: | | ||
git checkout release | ||
git fetch origin main | ||
if git diff --quiet origin/main; then | ||
echo "No differences, safe to proceed." | ||
else | ||
echo "::error::Differences found between release and main!" | ||
exit 1 | ||
- name: Reset release branch to main | ||
if: steps.diff-check.outcome == 'success' # Only proceed if no differences found | ||
run: | | ||
git reset --hard origin/main | ||
- name: Force push release branch | ||
if: steps.diff-check.outcome == 'success' | ||
run: git push origin release --force | ||
|
||
- name: Notify via GitHub Issue if differences found | ||
if: failure() # This runs if there were differences found and the job failed | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const { context, github } = require('@actions/github'); | ||
await github.issues.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: 'Sync Failure: Differences found between main and release', | ||
body: 'There are differences between `main` and `release` branches that prevented synchronization. Please review the branches and resolve manually.' | ||
}); |