Skip to content

Commit a557869

Browse files
authored
Update sync-fork workflow (#49)
1 parent 7fc9bc3 commit a557869

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

.github/workflows/sync-fork.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ jobs:
1010
sync:
1111
if: github.repository == 'ShreyashSri/pbctf'
1212
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
branch: [prod, staging] # Each branch syncs from its matching upstream branch
1317
permissions:
1418
contents: write # Required to push to the repository
1519

1620
steps:
1721
- name: Checkout repository
1822
uses: actions/checkout@v4
1923
with:
24+
ref: ${{ matrix.branch }}
2025
fetch-depth: 0 # Fetch all history for proper merging
2126
token: ${{ secrets.PAT_TOKEN }}
2227

@@ -39,20 +44,15 @@ jobs:
3944
- name: Fetch upstream
4045
run: git fetch upstream
4146

42-
- name: Get current branch
43-
id: branch
44-
run: echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
45-
4647
- name: Merge upstream changes
4748
run: |
48-
CURRENT_BRANCH="${{ steps.branch.outputs.branch }}"
49-
UPSTREAM_BRANCH="prod" # Upstream default branch
49+
BRANCH="${{ matrix.branch }}"
5050
51-
git checkout $CURRENT_BRANCH
51+
git checkout $BRANCH
5252
53-
# Try to merge from upstream branch
54-
if git merge "upstream/$UPSTREAM_BRANCH" --no-edit; then
55-
echo "Successfully merged upstream/$UPSTREAM_BRANCH into $CURRENT_BRANCH"
53+
# Try to merge from the matching upstream branch
54+
if git merge "upstream/$BRANCH" --no-edit; then
55+
echo "Successfully merged upstream/$BRANCH into $BRANCH"
5656
else
5757
echo "Merge failed or no changes to merge"
5858
# Check if there are actual conflicts or just no changes
@@ -67,9 +67,9 @@ jobs:
6767
6868
- name: Push changes
6969
run: |
70-
CURRENT_BRANCH="${{ steps.branch.outputs.branch }}"
71-
if git push origin $CURRENT_BRANCH; then
72-
echo "Successfully pushed changes to $CURRENT_BRANCH"
70+
BRANCH="${{ matrix.branch }}"
71+
if git push origin $BRANCH; then
72+
echo "Successfully pushed changes to $BRANCH"
7373
else
7474
echo "No changes to push or push failed"
7575
exit 0

0 commit comments

Comments
 (0)