-
Notifications
You must be signed in to change notification settings - Fork 6
Create sync-forks.yml #517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
|
|
||
| - 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" \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, maybe we can integrate variable
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
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