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

Deployment fails if BRANCH already exists on remote #43

Closed
sudkumar opened this issue Nov 3, 2019 · 10 comments
Closed

Deployment fails if BRANCH already exists on remote #43

sudkumar opened this issue Nov 3, 2019 · 10 comments
Labels
bug 🐦 Something isn't working version 3 Issues related to version 3 of this action.

Comments

@sudkumar
Copy link

sudkumar commented Nov 3, 2019

Describe the bug

Please provide a clear and concise description of what the bug is.

I have developed a portfolio website of mine which I want to host on github pages at https://sudkumar.github.io/. My development branch is src and the master branch should contain the website code (build folder). I have integrated the actions and it worked for the first deployment and created a master branch from my build folder (here). But when deploying again (now the master branch already exists on remote), the deployment deletes the master branch without creating it again (here). And this happens for all alternate deployments.

It throws this error.

Deploying to GitHub...
Error: Use --prefix instead of bare filenames.
To https://github.com/sudkumar/sudkumar.github.io.git
 - [deleted]         master
Deployment succesful!

Reproduce

Steps to reproduce the behavior.

Please have a look at my deployment actions

Expected behavior

Please provide a clear and concise description of what you expected to happen.

I expect it to push the new deployment to the master branch with the new commit.

Work Around
I have created a step to delete the master branch before the deployment step.

https://github.com/sudkumar/sudkumar.github.io/blob/5e166f27170660561d48156fd45498b627ec40ae/.github/workflows/deploy.yml#L16-L23

Please let me know if you need more details or I can be of some help in resolving this issue.

@sudkumar
Copy link
Author

sudkumar commented Nov 3, 2019

I cloned your action locally to test the deployment and added some echo statements. I found out that git subtree split --prefix $FOLDER $BASE_BRANCH throws this error when deploying again.

Error: Use --prefix instead of bare filenames.

@sudkumar
Copy link
Author

sudkumar commented Nov 3, 2019

I tested git subtree split --prefix $FOLDER $BASE_BRANCH locally to get the hash and it works just fine. It may be an issue with git version but I am not sure.

I update this command with

https://github.com/sudkumar/github-pages-deploy-action/blob/6948c4c28cb32c78204f2fc8686ec8dc9ea87537/entrypoint.sh#L88-L92

git subtree split --prefix $FOLDER --branch ${BASE_BRANCH}_build

and it is working. I don't know what the issue was or is it the correct way of doing it. Please suggest.

@evamaxfield
Copy link

evamaxfield commented Nov 5, 2019

My team also ran into this issue as well. We believed the issue was due to GitHub not liking that there was only ever a single commit in the gh-pages branch / whichever branch you deploy to. Something to do with their caching mechanism maybe? Regardless, we also wanted there to be a git history for the deploy branch so we made more extensive changes.

A bulk of the changes are in this commit but the current @master version is here.

Note: My fork is ran in an ubuntu / python image so we can build docs and such.

On higher level, I would assume these issues are naturally resolved by version three and both @sudkumar and my fixes are temporary solutions until that is released.

@sudkumar
Copy link
Author

sudkumar commented Nov 6, 2019

@JacksonMaxfield Thanks. Yours is much better than mine as keeping the history is essential. My gh-pages stopped working (no idea why 😕 ) after the actions integration. I will give yous a try.

@JamesIves
Copy link
Owner

Just catching up on this now as I’ve been traveling. I’ll see what I can do about pushing up version 3 this weekend.

@sudkumar
Copy link
Author

sudkumar commented Nov 7, 2019

@JamesIves Thank you. Please let me know if any way I can help in the release.

@JamesIves
Copy link
Owner

#44 PR is up for the release, still a few more things to finish up but it should be testable now.

@JamesIves
Copy link
Owner

Alright! I've finalized most of the details and I'm ready for some people to give this a try. I'd love to push this up before I fly to San Francisco for Chrome Dev Summit.

You can try the beta out using the following: JamesIves/github-pages-deploy-action@releases/v3-beta. Let me know if you spot any issues.

@sudkumar
Copy link
Author

sudkumar commented Nov 9, 2019

Hi @JamesIves I tried the v3-beta but got the following error.

git ls-remote --heads https://***@github.com/sudkumar/sudkumar.github.io.git master | wc -l
068dab7e7778d41ef7391d733959ef0af48e2c6b	refs/heads/master
git checkout src
fatal: 'src' could be both a local file and a tracking branch.
Please use -- (and optionally --no-guess) to disambiguate
##[error]The process 'git' failed with exit code 128
Deployment Successful!
##[error]Node run failed with exit code 1

Deployment

Logs
Run JamesIves/github-pages-deploy-action@releases/v3-beta
git init
Reinitialized existing Git repository in /home/runner/work/sudkumar.github.io/sudkumar.github.io/.git/
git config user.name sudkumar
git config user.email 6812992+sudkumar@users.noreply.github.com
git ls-remote --heads https://***@github.com/sudkumar/sudkumar.github.io.git master | wc -l
068dab7e7778d41ef7391d733959ef0af48e2c6b	refs/heads/master
git checkout src
fatal: 'src' could be both a local file and a tracking branch.
Please use -- (and optionally --no-guess) to disambiguate
##[error]The process 'git' failed with exit code 128
Deployment Successful!
##[error]Node run failed with exit code 1
Workflow
name: Build and Deploy
on:
  push:
    branches:
      - src
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Use Node.js
        uses: actions/setup-node@v1

      - name: Install
        env:
          CI: true
        run: |
          npm ci

      - name: Semantic Release
        uses: cycjimmy/semantic-release-action@v2
        id: semantic # Need an `id` for output variables
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: 000000000000000

      - name: Build
        env:
          CI: true
        run: |
          npm run-script build

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3-beta
        with:
          ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
          BASE_BRANCH: src # The branch the action should deploy from.
          BRANCH: master # The branch the action should deploy to.
          FOLDER: public # The folder the action should deploy.
          BUILD_SCRIPT: npm run-script build # The build script the action should run prior to deploying.
          COMMIT_NAME: Sudhir Mitharwal

@JamesIves
Copy link
Owner

Moving this to its own issue @sudkumar #45

@JamesIves JamesIves added bug 🐦 Something isn't working version 3 Issues related to version 3 of this action. labels Nov 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐦 Something isn't working version 3 Issues related to version 3 of this action.
Projects
None yet
Development

No branches or pull requests

3 participants