Skip to content

Commit

Permalink
Merge pull request #8 from use-the-fork/update-9071529212
Browse files Browse the repository at this point in the history
Update from upstream
  • Loading branch information
use-the-fork authored May 14, 2024
2 parents f94192b + a785178 commit 8f8a862
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/create_pr.yml
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 }}

0 comments on commit 8f8a862

Please sign in to comment.