Skip to content
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

bug: 🐝 fatal: 'origin/gh-pages' is not a commit and a branch 'gh-pages' cannot be created from it #1689

Closed
Hokkaydo opened this issue Sep 22, 2024 · 9 comments
Assignees
Labels
bug 🐝 This issue describes a bug. researching 📒 Currently researching potential fixes.

Comments

@Hokkaydo
Copy link

Hokkaydo commented Sep 22, 2024

Describe the bug

Receiveing :
fatal: 'origin/gh-pages' is not a commit and a branch 'gh-pages' cannot be created from it Error encountered while checking out branch. Attempting to continue with a new branch name.

If no gh-pages branch already exists, everything goes well except the branch isn't created so nothing is deployed

Reproduction Steps

Run the given yaml script with an already existing deploy branch. Was working when using v4 at a time but not anymore so I updated and still not working. The repository is this one

Logs

Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/EPLStudents/eplstudents.github.io.git refs/heads/gh-pages
6fbcef37e6b0171a0c0a402dcf8dda0b7eb619e0	refs/heads/gh-pages
Creating worktree…
/usr/bin/git fetch --no-recurse-submodules --depth=1 origin gh-pages
From https://github.com/EPLStudents/eplstudents.github.io
 * branch            refs/gh-pages -> FETCH_HEAD
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD 8c53f48)
/usr/bin/git checkout -B gh-pages origin/gh-pages
fatal: 'origin/gh-pages' is not a commit and a branch 'gh-pages' cannot be created from it
Error encountered while checking out branch. Attempting to continue with a new branch name.
/usr/bin/git checkout -B temp-1727024220934 origin/gh-pages
fatal: 'origin/gh-pages' is not a commit and a branch 'temp-1727024220934' cannot be created from it
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/zo89g44m4
Switched to a new branch 'github-pages-deploy-action/zo89g44m4'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Error: The deploy step encountered an error: There was an error creating the worktree: The process '/usr/bin/git' failed with exit code 128 ❌ ❌
Notice: Deployment failed! ❌

Workflow

name: Deploy to GitHub Pages

on:
  push:
    branches:
      - master
permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4.1.7 # This action checks out your repository
      - name: Run gen_static.sh script
        run: sh gen_static.sh
      - name: Build and Deploy
        uses: JamesIves/github-pages-deploy-action@v4.6.4
        with:
          token: ${{ secrets.GITHUB_TOKEN }} 
          branch: gh-pages
          folder: static
          clean: true

Additional Comments

No response

@Hokkaydo Hokkaydo added bug 🐝 This issue describes a bug. triage ⚠️ labels Sep 22, 2024
@JamesIves
Copy link
Owner

JamesIves commented Sep 23, 2024

What happens if you remove the token parameter and use the default built in GitHub token? Tried to repro this via the integration tests but was unable, makes me curious if there's some sort of scope problem manifesting here 🤔

@Hokkaydo
Copy link
Author

I tried both. To be fair, I was not using the token parameter at first and then tried with it but nothing changed :(

@JamesIves
Copy link
Owner

JamesIves commented Sep 26, 2024

Do you have any branch protection rules, or any other sort of repo settings that could be interfereing with branch creation? I forked your project in a test org and I was able to get it to work, both when a gh-pages branch doesn't exist, and when it does. You can view the workflow logs here: https://github.com/jives-test-org/eplstudents.github.io/actions

name: Deploy to GitHub Pages

on:
  push:
    branches:
      - master
permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4.1.7 # This action checks out your repository
      - name: Run gen_static.sh script
        run: sh gen_static.sh
      - name: Build and Deploy
        uses: JamesIves/github-pages-deploy-action@v4.6.4
        with:
          branch: gh-pages
          folder: static
          clean: true

Deployed: https://jives-test-org.github.io/eplstudents.github.io/

@JamesIves JamesIves added researching 📒 Currently researching potential fixes. and removed triage ⚠️ labels Sep 28, 2024
@JamesIves
Copy link
Owner

JamesIves commented Sep 29, 2024

I was able to reproduce this under very specific circumstances, can you give v4.6.8 a try? If you're still having troubles I will re-open this issue.

@Hokkaydo
Copy link
Author

Hokkaydo commented Oct 1, 2024

Hey, sorry for being back so late. It's still the same scenario :(
When the branch exists, it fails, when it doesn't it succeeds without creating it.

This is without an existing gh-pages branch

Checking if there are files to commit…
/usr/bin/git add --all .
/usr/bin/git checkout -b github-pages-deploy-action/7pn97u8vu
Switched to a new branch 'github-pages-deploy-action/7pn97u8vu'
/usr/bin/git commit -m Deploying to gh-pages from @ EPLStudents/eplstudents.github.io@03b7727e66655eca156f0f46871d0d4ceff56af5 🚀 --quiet --no-verify
Force-pushing changes...
/usr/bin/git push --force ***github.com/EPLStudents/eplstudents.github.io.git github-pages-deploy-action/7pn97u8vu:gh-pages
To https://github.com/EPLStudents/eplstudents.github.io.git
 + 9b620ce...f0ada56 github-pages-deploy-action/7pn97u8vu -> refs/gh-pages (forced update)
Changes committed to the gh-pages branch… 📦
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/7pn97u8vu
Reset branch 'github-pages-deploy-action/7pn97u8vu'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Completed deployment successfully! ✅

And this when it exists

Checking if there are files to commit…
/usr/bin/git add --all .
/usr/bin/git checkout -b github-pages-deploy-action/wxdq3ix31
Switched to a new branch 'github-pages-deploy-action/wxdq3ix31'
/usr/bin/git commit -m Deploying to gh-pages from @ EPLStudents/eplstudents.github.io@03b7727e66655eca156f0f46871d0d4ceff56af5 🚀 --quiet --no-verify
Force-pushing changes...
/usr/bin/git push --force ***github.com/EPLStudents/eplstudents.github.io.git github-pages-deploy-action/wxdq3ix31:gh-pages
error: dst refspec gh-pages matches more than one
error: failed to push some refs to 'https://github.com/EPLStudents/eplstudents.github.io.git'
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/wxdq3ix31
Reset branch 'github-pages-deploy-action/wxdq3ix31'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Error: The deploy step encountered an error: The process '/usr/bin/git' failed with exit code 1 ❌
Notice: Deployment failed! ❌
##[debug]Node Action run completed with exit code 1
##[debug]deployment_status='failed'
##[debug]Set output deployment-status = failed
##[debug]Finishing: Build and Deploy

It looks like the problem is right there error: dst refspec gh-pages matches more than one but I don't have any other tag nor release matching gh-pages. I've seen it's possible to specify refs/head/<branch_name> to tell git to look for a branch but I don't know if it would solve the problem

And to answer your questions on branch protection rules, none of them is enabled

@JamesIves
Copy link
Owner

Are you pushing commits one directly after another? I see that both jobs in your workflows happened very shortly after one another. If there's two git operations ongoing at once, it will cause problems.

Can you try adding concurrency: ci-${{ github.ref }} to your job?

name: Deploy to GitHub Pages

on:
  push:
    branches:
      - master
permissions:
  contents: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    concurrency: ci-${{ github.ref }}
    steps:
      - uses: actions/checkout@v4.1.7 # This action checks out your repository
      - name: Run gen_static.sh script
        run: sh gen_static.sh
      - name: Build and Deploy
        uses: JamesIves/github-pages-deploy-action@v4.6.4
        with:
          branch: gh-pages
          folder: static
          clean: true

This will make it so only a single deployment job occurs at once

@Hokkaydo
Copy link
Author

Hokkaydo commented Oct 1, 2024

I just re-run workflows while testing different configurations so this may explain the short timings between runs.
But all the problems happened when only one job was running.

I ran with the concurrency setting and still the same result :x

@JamesIves
Copy link
Owner

JamesIves commented Oct 1, 2024

Really weird. When you're trying with an existing branch, is this after the action has made the first push to the gh-pages branch? When I look at the gh-pages branch in your repo the commit messages do not match one that the action makes. Could imply that there's something to do with how the branch was originally pushed but hard to say.

I've tried to reproduce this a number of different ways but haven't seem to find what's causing this yet.

@Hokkaydo
Copy link
Author

Hokkaydo commented Oct 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐝 This issue describes a bug. researching 📒 Currently researching potential fixes.
Projects
None yet
Development

No branches or pull requests

2 participants