-
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.
Merge pull request #8 from use-the-fork/update-9071529212
Update from upstream
- Loading branch information
Showing
1 changed file
with
70 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,70 @@ | ||
name: Sync Fork with Upstream and Create PR | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
sync-and-pr: | ||
runs-on: ubuntu-latest | ||
if: github.repository != 'Spacebar-Cowboys/nyx' # Ensure it does not run in the original repository | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Git | ||
run: | | ||
git config --global user.name "${{ github.actor }}" | ||
git config --global user.email "${{ github.actor }}@users.noreply.github.com" | ||
- name: Create dynamic branch for PR | ||
run: | | ||
git checkout -b "update-${{ github.run_id }}" | ||
- name: Fetch original | ||
run: | | ||
git remote add upstream https://github.com/Spacebar-Cowboys/nyx.git | ||
git fetch upstream | ||
- name: Temporarily ignore certain directories | ||
run: | | ||
echo "systems/x86_64-linux/" >> .gitignore | ||
echo "homes/" >> .gitignore | ||
git config --global core.excludesfile .gitignore | ||
- name: Merge changes excluding specific directories | ||
run: | | ||
git checkout main | ||
git restore --source upstream/main --staged --worktree -- . | ||
git add . | ||
git reset -- .gitignore # Make sure .gitignore itself is not committed | ||
- name: Commit changes | ||
run: | | ||
if git commit -m "Syncing changes with upstream excluding specific directories"; then | ||
echo "Changes committed." | ||
else | ||
echo "No changes to commit." | ||
fi | ||
- name: Push changes to GitHub | ||
run: | | ||
git push --set-upstream origin "update-${{ github.run_id }}" | ||
- name: Create or Update Pull Request | ||
run: | | ||
gh pr create --title "Update from upstream" \ | ||
--body "Merged changes from the original repository excluding 'systems/x86_64-linux' and 'homes' directories." \ | ||
--head "${{ github.actor }}:update-${{ github.run_id }}" \ | ||
--base main \ | ||
--repo Spacebar-Cowboys/nyx \ | ||
--fill || echo "Error or no changes to create a PR." | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.MY_PERSONAL_TOKEN }} |