Skip to content
Open
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
61 changes: 61 additions & 0 deletions .github/workflows/sync-forks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Propose Template Changes to Forks

on:
push:
branches:
- develop # When template's develop is updated

jobs:
propose-sync:
runs-on: ubuntu-latest

steps:
- name: Checkout Template Repo
uses: actions/checkout@v3

- name: Set up Git identity
run: |
git config --global user.name "IEEEAutomationBot"
git config --global user.email "webmaster@ieee.utoronto.ca"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this user has the necessary permissions to submit PRs for the other repos

Copy link
Copy Markdown
Contributor

@carmen-chau carmen-chau May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this user has the necessary permissions to submit PRs for the other repos

I think this is probably covered by grabbing the GH_TOKEN from what I presume is this hackathon template repo (secrets config settings), @guaaaaa correct me if I'm wrong

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is user should have all access (if i set everything correctly). The GH_TOKEN is for authorization purpose.

You can see more details here in the "GitOps" section https://docs.google.com/document/d/1LMUwCeKUJjQRd3DhIZ-CZVeheR7SCSmE/edit?usp=sharing&ouid=111047183552148011769&rtpof=true&sd=true


- name: Install GitHub CLI
uses: cli/cli-action@v2

- name: Push develop branch to forks
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
FORKS=(
"ieeeuoft/newhacks"
# "ieeeuoft/aws"
# "ieeeuoft/makeuoft"
)
for FORK in "${FORKS[@]}"; do
REPO_NAME=$(basename $FORK)
BRANCH_NAME=template-proposal-$(date +%s)

echo "📤 Pushing develop to fork: $REPO_NAME"

# Clone the fork
git clone https://x-access-token:${GH_TOKEN}@github.com/${FORK}.git
cd $REPO_NAME

# Create a new branch from local develop
git checkout -b $BRANCH_NAME
git remote add template https://github.com/ieeeuoft/hackathon-template.git
git fetch template develop

# Overwrite this branch with template's develop
git reset --hard template/develop

git push origin $BRANCH_NAME

# Create PR into fork's develop branch
gh pr create --repo $FORK \
--title "🔄 Sync from hackathon-template" \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all PRs created will have the same PR title? If there is multiple PRs with the same title it would be confusing.

Copy link
Copy Markdown
Contributor

@carmen-chau carmen-chau May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, maybe we can integrate variable $REPO_NAME in the commit message and body to better differentiate?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a note of this and will come back to this. For now, i'll first make sure the process can create a PR

--body "Auto-sync from template repo develop branch." \
--base develop \
--head $BRANCH_NAME || echo "⚠️ PR may already exist"

cd ..
done
Loading