actions-gh-pages icon indicating copy to clipboard operation
actions-gh-pages copied to clipboard

support: self-hosted runner publishes directory with weird prefix

Open dhimmel opened this issue 2 years ago • 10 comments

I recently switched a workflow that includes peaceiris/actions-gh-pages to use a self-hosted runner.

When using peaceiris/actions-gh-pages@v3 and when the output branch doesn't already exist, the deploy step succeeded but placed the published data under a prefix, i.e. the output was written to undefined/actions_github_pages_1651252139745/test.json instead of just test.json. Here are links for the workflow, the job log, and output branch. Some key lines of output:

INFO:nxontology_data.utils:Wrote ontology to /actions-runner/_work/nxontology-data/nxontology-data/output/test/test.json
...

/usr/bin/git clone --depth=1 --single-branch --branch output/test ***github.com/related-sciences/nxontology-data.git undefined/actions_github_pages_1651252139745
  Cloning into 'undefined/actions_github_pages_1651252139745'...
  warning: Could not find remote branch output/test to clone.
  fatal: Remote branch output/test not found in upstream origin
  [INFO] first deployment, create new branch output/test
  [INFO] The process '/usr/bin/git' failed with exit code 128
  [INFO] chdir undefined/actions_github_pages_16512521397[45](https://github.com/related-sciences/nxontology-data/runs/6232229406?check_suite_focus=true#step:6:45)
  /usr/bin/git init
  Initialized empty Git repository in /actions-runner/_work/nxontology-data/nxontology-data/undefined/actions_github_pages_1651252139745/.git/
  /usr/bin/git checkout --orphan output/test
  Switched to a new branch 'output/test'
  [INFO] prepare publishing assets
  [INFO] create undefined/actions_github_pages_1651252139745
  [INFO] copy /actions-runner/_work/nxontology-data/nxontology-data/output/test to undefined/actions_github_pages_1651252139745
  cp: no such file or directory: /actions-runner/_work/nxontology-data/nxontology-data/output/test/.*

When using peaceiris/actions-gh-pages@main, I got a failure:

Error: File not found: '/actions-runner/_work/_actions/peaceiris/actions-gh-pages/main/lib/index.js'

When using peaceiris/actions-gh-pages@v3 but when the output branch already exists, I get:

  /usr/bin/git push origin output/test
  To https://github.com/related-sciences/nxontology-data.git
   ! [rejected]        output/test -> output/test (fetch first)
  error: failed to push some refs to '***github.com/related-sciences/nxontology-data.git'
  hint: Updates were rejected because the remote contains work that you do
  hint: not have locally. This is usually caused by another repository pushing
  hint: to the same ref. You may want to first integrate the remote changes
  hint: (e.g., 'git pull ...') before pushing again.
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  Error: Action failed with "The process '/usr/bin/git' failed with exit code 1"

So not sure exactly how to proceed.

Relevant links

Public repository: https://github.com/related-sciences/nxontology-data YAML config: https://github.com/related-sciences/nxontology-data/blob/6b43ce4927641f43baebc3e077e0c56a32fdf53f/.github/workflows/create.yaml

dhimmel avatar Apr 29 '22 17:04 dhimmel

@peaceiris any insights here? Happy to help diagnose.

dhimmel avatar May 07 '22 12:05 dhimmel

started getting that with ForceOrphan: true

pavlovp avatar May 27 '22 11:05 pavlovp

started getting that with ForceOrphan: true

Thanks @pavlovp for commenting. Specifically which part since there are several potential issues / symptoms here?

dhimmel avatar May 27 '22 15:05 dhimmel

My github actions pipeline:

  - name: build-docs
    run: npm run build:docs
  - name: Deploy-docs
    uses: peaceiris/[email protected]
    with:
      github_token: ${{ secrets.GITHUB_TOKEN }}
      publish_dir: ./docs
      destination_dir: docs
      force_orphan: true

Logs (actions tab):

Run peaceiris/[email protected] [INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme Dump inputs [INFO] GithubToken: true [INFO] PublishBranch: gh-pages [INFO] PublishDir: ./docs [INFO] DestinationDir: docs [INFO] ExternalRepository: [INFO] AllowEmptyCommit: false [INFO] KeepFiles: false [INFO] ForceOrphan: true [INFO] UserName: [INFO] UserEmail: [INFO] CommitMessage: [INFO] FullCommitMessage: [INFO] TagName: [INFO] TagMessage: [INFO] EnableJekyll (DisableNoJekyll): false [INFO] CNAME: [INFO] ExcludeAssets .github

Setup auth token [INFO] setup GITHUB_TOKEN Prepare publishing assets [INFO] ForceOrphan: true [INFO] chdir undefined/actions_github_pages_1653910528380 /usr/local/git/bin/git init Initialized empty Git repository in /var/actions/_work/project-name/project-name/undefined/actions_github_pages_1653910528380/.git/ /usr/local/git/bin/git checkout --orphan gh-pages Switched to a new branch 'gh-pages' [INFO] prepare publishing assets [INFO] create undefined/actions_github_pages_1653910528380/docs [INFO] copy /var/actions/_work/project-name/project-name/docs to undefined/actions_github_pages_1653910528380/docs [INFO] delete excluded assets cp: no such file or directory: /var/actions/_work/project-name/project-name/docs/.* rm: no paths given [INFO] Created undefined/actions_github_pages_1653910528380/.nojekyll

image

I'm wondering what cause this weird undefined/actions_github_pages_xxx folder to be created - when I navigate in the browser using this suffix I'm able to access the web app that is hosted in my github pages env.

pavlovp avatar May 30 '22 14:05 pavlovp

@peaceiris hoping to catch your eye here, especially since this would be great to get fixed in the next major release. The issue is that content is deployed to a directory like undefined/actions_github_pages_1651252139745 rather than being placed in the root of the branch.

I'm having this issue using a self-hosted runner and @pavlovp experienced this issue when setting force_orphan: true.

dhimmel avatar Oct 20 '22 16:10 dhimmel

@peaceiris any updates on this issue? I haven't tested with v3.9.1 yet, so let me know if any chance this is already fixed and I will reevaluate.

dhimmel avatar Jan 09 '23 18:01 dhimmel

I seem to have the same problem, everything seems to work fine when running actions runner with nohup, when I use supervisor to manage run.sh, I have a similar problem, I don't know if this is the reason for it. Here is my supervisor configuration.

[program:actions-runner]
directory=/home/ubuntu/actions-runner
command=/home/ubuntu/actions-runner/run.sh
autostart=true
autorestart=true
startretries=3
user=ubuntu
redirect_stderr=true
stdout_logfile=/home/ubuntu/actions-runner/logs/out.log
stderr_logfile=/home/ubuntu/actions-runner/logs/err.log

actions:

      - name: Push K8S Yaml
        uses: peaceiris/actions-gh-pages@v3
        if: ${{ inputs.config_stage == 'beta' }}
        with:
          personal_token: ${{ secrets.PERSONAL_TOKEN }}
          publish_dir: ./artifact/cdk8s/test
          keep_files: true
          publish_branch: ${{ github.repository }}
          external_repository: ${{ github.repository }}
          destination_dir: beta

Guessing it could be because of some missing environment variable? I read the source code and didn't find out what the problem was.

Thank you for your prompt response.

12ain avatar Jun 07 '23 07:06 12ain

@dhimmel, I've identified what the issue is. If you have configured the GitHub Actions self-hosted runner with the root user, you will encounter the error mentioned above.

Hansanghyeon avatar Dec 05 '23 09:12 Hansanghyeon

Got the same issues when running on self-hosted runner as root. My workaround was to use containers. I noticed that this has something to do with removing the repository: when root does it, it cleans up using git commands. However, when using containers, it gets fully removed and cloned again. Maybe it'll help somebody.

dywanik avatar Feb 29 '24 08:02 dywanik