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

Github Actions deployment error #2846

Closed
pdimens opened this issue May 30, 2020 · 20 comments
Closed

Github Actions deployment error #2846

pdimens opened this issue May 30, 2020 · 20 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. documentation The issue is related to the documentation of Docusaurus help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship

Comments

@pdimens
Copy link

pdimens commented May 30, 2020

🐛 Bug Report

(A clear and concise description of what the bug is)
Following the guidelines of GitHub Actions deployment here: https://v2.docusaurus.io/docs/deployment/#deploy
The actions fail to build and deploy the site with this error:

 Release to GitHub Pages5s
##[error]Process completed with exit code 1.
Run git config --global user.email "actions@gihub.com"
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-05-30T17_04_14_260Z-debug.log
##[error]Process completed with exit code 1.

To Reproduce

  1. Added contents of documentation.yml from https://v2.docusaurus.io/docs/deployment/#deploy to file .github/workflows/documentation.yml in documentation branch of repository
  2. Followed the instructions to generate/deploy ssh key and secret

Expected behavior

successfully build the site and deploy to branch gh-pages

Actual Behavior

The actions fail to build and deploy the site with this error:

 Release to GitHub Pages5s
##[error]Process completed with exit code 1.
Run git config --global user.email "actions@gihub.com"
npm ERR! cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-05-30T17_04_14_260Z-debug.log
##[error]Process completed with exit code 1.

Your Environment

  • Docusaurus version used: 2.0.0-alpha.56
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node v14.2.0
  • Operating system and version (desktop or mobile): Desktop Arch Linux

Reproducible Demo

https://github.com/pdimens/PopGen.jl/tree/documentation/.github/workflows

@pdimens pdimens added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels May 30, 2020
@lex111
Copy link
Contributor

lex111 commented May 30, 2020

@artemkovalyov could you please look at it?

@yangshun yangshun added documentation The issue is related to the documentation of Docusaurus help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. and removed status: needs triage This issue has not been triaged by maintainers labels Jun 5, 2020
@anshulrgoyal
Copy link
Contributor

anshulrgoyal commented Jun 8, 2020

I think the error is originating from missing package-lock.json since npm ci requires a lock file. And Check action is also not configured properly.
The following should fix check job

    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Deploy
        run: |
            npm ci
            npm run build

@anshulrgoyal
Copy link
Contributor

I will make a pr for check job and checking if a lock file is present before using npm ci and falling back to npm i

@pdimens
Copy link
Author

pdimens commented Jun 8, 2020

Given that yarn was used and created yarn.lock rather than package-lock.json, is that the origin of the issue for the missing package-lock.json?

@anshulrgoyal
Copy link
Contributor

anshulrgoyal commented Jun 8, 2020

npm ci is used in action so it will look for package-lock.json file i think so.

@anshulrgoyal
Copy link
Contributor

@pdimens npm doesn't recognize yarn.lock file, I will try to change npm to yarn automatically in the action based on the lock file

@pjoshi751
Copy link

Hi.. I am facing the same issue and cannot find package-lock.json file when I install docusaurus via
npx @docusaurus/init@next init [name] [template] as given in the documentation.

@slorber
Copy link
Collaborator

slorber commented Jun 11, 2020

Hey,

Using NPM ?

If you don't have a package-lock.json file, do you use npm locally?

If yes, have you run npm install locally?

Since npm5, all npm installs normally create a package-lock.json file.
Maybe you should upgrade to npm5 if you are using an older version (there are options to create a package-lock.json for older versions afaik)

Have you committed this lockfile? you should.

Using Yarn ?

Then you have a yarn.lock, and it would be better to use yarn in the CI to be sure to use the same versions in dev and CI (those in the lockfile)

So you should replace all NPM commands by yarn equivalent

yarn install --frozen-lockfile , according to https://stackoverflow.com/questions/58482655/what-is-the-closest-to-npm-ci-in-yarn

so when you see:

          run: |
            npm ci
            npm run build

You can replace by:

          run: |
            yarn install --frozen-lockfile
            yarn build

Don't forget to install yarn in the Github CI first: https://codyogden.blog/yarn-with-github-actions-ci-cd/

@pdimens
Copy link
Author

pdimens commented Jun 11, 2020

Following @slorber suggestion, I modified the GitHub Actions workflow to:

name: documentation

on:
  pull_request:
    branches: [documentation]
  push:
    branches: [documentation]

jobs:
  checks:
    if: github.event_name != 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - run: npm install -g yarn
      - name: Deploy
        run: |
          yarn install --frozen-lockfile
          yarn build
  gh-release:
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Add key to allow access to repository
        env:
          SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          cat <<EOT >> ~/.ssh/config
          Host github.com
          HostName github.com
          IdentityFile ~/.ssh/id_rsa
          EOT
      - name: Release to GitHub Pages
        env:
          USE_SSH: true
          GIT_USER: git
        run: |
          git config --global user.email "actions@gihub.com"
          git config --global user.name "gh-actions"
          npm ci
          npx docusaurus deploy

and the result now seems to be an authentication error. I am under the impression that I followed the documentation about this process correctly, but now I'm unsure.

Cloning into 'PopGen.jl-gh-pages'...
Warning: Permanently added the RSA host key for IP address '140.82.112.3' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Error: git clone failed
    at runDeploy (/home/runner/work/PopGen.jl/PopGen.jl/node_modules/@docusaurus/core/lib/commands/deploy.js:80:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
##[error]Process completed with exit code 1.

@slorber
Copy link
Collaborator

slorber commented Jun 11, 2020

@pdimens

fatal: Could not read from remote repository.

That does not seem related to docusaurus, you should refer to Github Actions doc for that imho. Maybe you have a problem with your GH_PAGES_DEPLOY, but I don't know, we are not Github CI experts here :)

Deploying to Github Pages looks really complicated to me.
I'd recommend you to try using Netlify (or Vercel), this is way simpler, free, has much more features, better UX, PR deployment previews...


@yangshun @JoelMarcey current docs seems to recommend Github Pages (at least it's the first thing users see). What about recommending something else, that is also free, and does not require complex CI setup? Github pages was nice a few years ago, as it was the only free static hosting provider, but since then, the market has changed a lot...

@anshulrgoyal
Copy link
Contributor

Following @slorber suggestion, I modified the GitHub Actions workflow to:

name: documentation

on:
  pull_request:
    branches: [documentation]
  push:
    branches: [documentation]

jobs:
  checks:
    if: github.event_name != 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - run: npm install -g yarn
      - name: Deploy
        run: |
          yarn install --frozen-lockfile
          yarn build
  gh-release:
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Add key to allow access to repository
        env:
          SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          mkdir -p ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
          echo "${{ secrets.GH_PAGES_DEPLOY }}" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          cat <<EOT >> ~/.ssh/config
          Host github.com
          HostName github.com
          IdentityFile ~/.ssh/id_rsa
          EOT
      - name: Release to GitHub Pages
        env:
          USE_SSH: true
          GIT_USER: git
        run: |
          git config --global user.email "actions@gihub.com"
          git config --global user.name "gh-actions"
          npm ci
          npx docusaurus deploy

and the result now seems to be an authentication error. I am under the impression that I followed the documentation about this process correctly, but now I'm unsure.

Cloning into 'PopGen.jl-gh-pages'...
Warning: Permanently added the RSA host key for IP address '140.82.112.3' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Error: git clone failed
    at runDeploy (/home/runner/work/PopGen.jl/PopGen.jl/node_modules/@docusaurus/core/lib/commands/deploy.js:80:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
##[error]Process completed with exit code 1.

It wouldn't work if u have passcode on ssh key

@pdimens
Copy link
Author

pdimens commented Jun 11, 2020

@anshulrgoyal I don't know if I do (pretty new to this) and don't recall setting it up in such a manner. I may have to retry the instructions on the docusaurus site.

@anshulrgoyal
Copy link
Contributor

anshulrgoyal commented Jun 11, 2020

@anshulrgoyal I don't know if I do (pretty new to this) and don't recall setting it up in such a manner. I may have to retry the instructions on the docusaurus site.

I have forked your repo and setted up GitHub action there using two different methods. U can try them. One of then doesn't require any config

@anshulrgoyal
Copy link
Contributor

@pdimens
Copy link
Author

pdimens commented Jun 11, 2020

@anshulrgoyal thank you! I still seem to have deployment/authentication issues though, but it's probably something incorrectly configured on my part?

Deploy command invoked ...
HEAD
https://github.com/pdimens/PopGen.jl
ee7b7cb2e32a66be4d4a2c117264fd6163976472
Creating an optimized production build...
[info] [webpackbar] Compiling Client
[info] [webpackbar] Compiling Server
[success] [webpackbar] Client: Compiled successfully in 25.64s
[success] [webpackbar] Server: Compiled successfully in 29.16s

Success! Generated static files in build.

Cloning into 'PopGen.jl-gh-pages'...
Warning: Permanently added the RSA host key for IP address '140.82.113.3' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Error: Error: git clone failed
    at runDeploy (/home/runner/work/PopGen.jl/PopGen.jl/node_modules/@docusaurus/core/lib/commands/deploy.js:80:19)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
##[error]Process completed with exit code 1.

@pdimens
Copy link
Author

pdimens commented Jun 12, 2020

@anshulrgoyal to follow up, I tried to see if it would make a difference to set up an SSH key for actions@github.com rather than the email account associated with my github account, and that seemed to do the trick. I pushed a minor commit and GitHub Actions finally ran the job successfully. If what I did was the the correct method all along, I recommend adding the specificity in the docusaurus deploy docs of creating an SSH key for actions@github.com .

@shinebayar-g
Copy link

shinebayar-g commented Jun 16, 2020

This action works just fine without creating SSH key, using default GITHUB_TOKEN key.
I think docusaurus' yarn deploy script could achieve the same thing.

@stevenguh
Copy link

This an example github action that I am using to deploy to gh pages with peaceiris/actions-gh-pages. This action works fine without a new deploy ssh key.

name: deploy

on:
  pull_request:
    branches: [master]
  push:
    branches: [master]

jobs:
  checks:
    if: github.event_name != 'push'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Test Build
        run: |
          if [ -e yarn.lock ]; then
          yarn install --frozen-lockfile
          elif [ -e package-lock.json ]; then
          npm ci
          else
          npm i
          fi
          npm run build
  gh-release:
    if: github.event_name != 'pull_request'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
      - name: Build
        run: |
          if [ -e yarn.lock ]; then
          yarn install --frozen-lockfile
          elif [ -e package-lock.json ]; then
          npm ci
          else
          npm i
          fi
          npm run build
      - name: Release to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./build

@ousmane0682
Copy link

very good

@muammadnoman
Copy link

I am getting this issue
image

When I try to execute the code on CI pipeline using Github Actions

Here is yml file
name: Genius Autos e2e Test

on:

Manual Button Click from Github UI

workflow_dispatch:

Pushing commit to the master branch

push:

# branches: master

schedule:
# Runs tests every day at 1am

  • cron: '0 1 * * *'

jobs:
cypress-run:
runs-on: ubuntu-latest
# Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# Also see warning here https://github.com/cypress-io/github-action#parallel
strategy:
fail-fast: false # cypress-io/github-action#48
steps:
- name: Checkout
uses: actions/checkout@v3
- name: e2e Test on Chrome
# Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
browser: chrome
headed: true
spec: Cypress/dismantly-tests/cypress/tests/Portal/*.ts
# Records to Cypress Cloud
# https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
record: true
parallel: true # Runs test in parallel using settings above
env:
# For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
# in GitHub repo → Settings → Secrets → Actions
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_TOKEN: ${{ secrets.CIAN_TOKEN }}
- name: Uploading artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: cypress-execution-report
path: cypress/reports/html
retention-days: 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution difficulty: starter Issues that are starter difficulty level, e.g. minimal tweaking with a clear test plan. documentation The issue is related to the documentation of Docusaurus help wanted Asking for outside help and/or contributions to this particular issue or PR. mlh Major League Hacking Fellowship
Projects
None yet
Development

No branches or pull requests