Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/sync-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ jobs:
sync:
if: github.repository == 'ShreyashSri/pbctf'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
branch: [prod, staging] # Each branch syncs from its matching upstream branch
permissions:
contents: write # Required to push to the repository

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
fetch-depth: 0 # Fetch all history for proper merging
token: ${{ secrets.PAT_TOKEN }}

Expand All @@ -39,20 +44,15 @@ jobs:
- name: Fetch upstream
run: git fetch upstream

- name: Get current branch
id: branch
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT

- name: Merge upstream changes
run: |
CURRENT_BRANCH="${{ steps.branch.outputs.branch }}"
UPSTREAM_BRANCH="prod" # Upstream default branch
BRANCH="${{ matrix.branch }}"

git checkout $CURRENT_BRANCH
git checkout $BRANCH

# Try to merge from upstream branch
if git merge "upstream/$UPSTREAM_BRANCH" --no-edit; then
echo "Successfully merged upstream/$UPSTREAM_BRANCH into $CURRENT_BRANCH"
# Try to merge from the matching upstream branch
if git merge "upstream/$BRANCH" --no-edit; then
echo "Successfully merged upstream/$BRANCH into $BRANCH"
else
echo "Merge failed or no changes to merge"
# Check if there are actual conflicts or just no changes
Expand All @@ -67,9 +67,9 @@ jobs:

- name: Push changes
run: |
CURRENT_BRANCH="${{ steps.branch.outputs.branch }}"
if git push origin $CURRENT_BRANCH; then
echo "Successfully pushed changes to $CURRENT_BRANCH"
BRANCH="${{ matrix.branch }}"
if git push origin $BRANCH; then
echo "Successfully pushed changes to $BRANCH"
else
echo "No changes to push or push failed"
exit 0
Expand Down
Loading