rayluo / github-pages-overwriter

A Github Action that overwrites your Github Pages branch with the content of current workdir, thus deploy/publish without polluting your repo history.
MIT License
38 stars 2 forks source link

GPO deleted `gh-pages` branch #2

Closed vadi2 closed 2 years ago

vadi2 commented 2 years ago

For some reason in this run, GPO deleted my gh-pages branch, which ended up deleting the website and any associated github pages configuration:

Run rayluo/github-pages-overwriter@v1.2
Run # The following 2 lines are not really necessary,
Switched to branch 'gh-pages'
[gh-pages 186cc40] Automated publish
 2 files changed, 592 insertions(+)
 create mode 100644 package-lock.json
 create mode 100644 package.json
Run if [ "dist" == "." ]; then
  if [ "dist" == "." ]; then
    git push -f origin HEAD:refs/heads/gh-pages
  else
    # Inspired from https://gist.github.com/cobyism/4730490#gistcomment-1374989
    git push -f origin `git subtree split -P dist`:refs/heads/gh-pages
  fi
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
1/3 (0) [0]
2/3 (1) [0]
3/3 (2) [0]
No new revisions were found
To https://github.com/health-validator/Hammer
 - [deleted]         gh-pages

Any ideas why did it happen?

vadi2 commented 2 years ago

Deletion of gh-pages also nuked the entire configuration of github pages, which is unfortunate and somewhat unexpected.

rayluo commented 2 years ago

For some reason in this run, GPO deleted my gh-pages branch, which ended up deleting the website and any associated github pages configuration

Hi @vadi2 , sorry for my not noticing your message until months later. (But you switched to a different github action immediately, so I guess I wouldn't be able to help even if I noticed it within days.)

Anyway. Trying to answer your question now, without original logs, my guess is your previous action in your workflow somehow failed and generated nothing into your publish folder /dist. In such an unexpected corner case, GPO possibly created an empty gh-pages branch, which in term caused git to delete that branch.

I would assume that, if you fix your previous action, the GPO would then automatically recover.

Deletion of gh-pages also nuked the entire configuration of github pages, which is unfortunate and somewhat unexpected.

This part is probably a github behavior. But the good news is, it seems like nowadays github would also automatically create github pages settings, once a gh-pages branch is created again.

Closing for now. Feel free to contact me if you would use GPO and run into issues again.

julianfortune commented 1 year ago

@rayluo Just encountered the same issue and the folder is definitely not empty 🤔

julianfortune commented 1 year ago

Perhaps my .gitignore ignoring the build site's build directory is causing the issue?

julianfortune commented 1 year ago

Could https://github.com/rayluo/github-pages-overwriter/blob/dev/action.yml#L40 become

git add --force ${{ inputs.source-directory }}

?

im7mortal commented 5 months ago

Hi @rayluo


Run if [ "build" == "." ]; then
1/2 (0) [0]
2/2 (1) [0]
fatal: no new revisions were found
To https://github.com/im7mortal/unrpa
 - [deleted]         gh-pages

I believe I have the same problem

  1. It fails silently
  2. It mess up with gh pages settings

    I checked source code and I don't have idea for now what could be the reason.

rayluo commented 5 months ago

I do not currently know the exact reason, so, please bear with me on the following hypothesis. Based on the limited reports (only two so far), there seems to be a common factor between @im7mortal 's report and the original report by @vadi2 , that your repositories do not already contain the target directory ("build" in @im7mortal 's case and "dist" in @vadi2 's case). As a comparison, in my own REPOs that use GPO, such as this one, the target directory already exists in the code base.

So, perhaps @im7mortal you can try adding a /build/placeholder.txt file into your code base and see whether it makes a difference. Please let me know the result. UPDATE: That idea might be irrelevant. I re-read this project's README and it has this explicit wording "Such a directory does not have to already exist in your repo". :man_shrugging:

im7mortal commented 5 months ago

@rayluo for now I copied workflow directly to the my pipeline and it started to work.

I will try to narrow down the issue