PR: troubleshooting the PR not being created

This commit is contained in:
XargonWan 2024-11-06 10:10:26 +09:00
parent 3c6b0c498e
commit ac5344cca5

View file

@ -45,44 +45,41 @@ jobs:
- name: Sync from Upstream Repository
env:
BRANCH_NAME: "sync-${{ github.run_id }}" # Temporary branch name for the PR
BRANCH_NAME: "feat/update-from-upstream"
run: |
echo "Syncing from upstream repository ${{ env.UPSTREAM_REPO }} on branch ${{ env.TARGET_BRANCH }}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
# Fetch and delete the branch if it exists locally
git fetch origin
if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then
echo "Branch $BRANCH_NAME exists locally. Deleting it."
git branch -D "$BRANCH_NAME"
fi
# Check if the branch exists on the remote and delete it if it does
if git ls-remote --heads origin "$BRANCH_NAME" | grep "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME exists on the remote. Deleting it."
git push origin --delete "$BRANCH_NAME"
# Switches or creates update branch
if git show-ref --verify --quiet "refs/heads/$BRANCH_NAME"; then
git checkout "$BRANCH_NAME"
else
git checkout -b "$BRANCH_NAME"
fi
# Fetch changes from the upstream repository without merging
git fetch "${{ env.UPSTREAM_REPO }}" "${{ env.TARGET_BRANCH }}"
# Create a new branch and apply the upstream changes
git checkout -b "$BRANCH_NAME"
git reset --hard FETCH_HEAD
# Check if there are any changes to commit
if git diff --exit-code origin/${{ env.TARGET_BRANCH }}; then
if git diff --exit-code "origin/${{ env.TARGET_BRANCH }}"; then
echo "No changes detected from upstream. Exiting without creating PR."
echo "SKIP_PR=true" >> $GITHUB_ENV
else
git add -A
git commit -m "Updating ${{ github.event.repository.name }} with upstream changes"
echo "SKIP_PR=false" >> $GITHUB_ENV
fi
- name: Push changes to new branch
if: success()
if: success() && env.SKIP_PR == 'false'
run: |
git push origin "${{ env.BRANCH_NAME }}"
- name: Create Pull Request
if: success()
if: success() && env.SKIP_PR == 'false'
uses: peter-evans/create-pull-request@v7.0.5
with:
token: ${{ steps.generate-rekku-token.outputs.token || secrets.GITHUB_TOKEN }}
@ -129,3 +126,4 @@ jobs:
git push origin ${{ env.BRANCH_NAME }}
```
base: ${{ env.TARGET_BRANCH }}