JamesIves / github-pages-deploy-action

🚀 Automatically deploy your project to GitHub Pages using GitHub Actions. This action can be configured to push your production-ready code into any branch you'd like.
https://github.com/marketplace/actions/deploy-to-github-pages
MIT License
4.29k stars 360 forks source link

Issue with rsync and build file path #102

Closed gingerchew closed 4 years ago

gingerchew commented 4 years ago

Describe the bug

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

While the action is processing, everything goes fine until near the end of the process it says:

rsync: change_dir "/home/runner/work/documentation/documentation//build" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
The deployment encountered an error. ❌
##[error]The process 'rsync' failed with exit code 23

Similar to issue #84

Reproduce

Steps to reproduce the behavior.

I'm not sure the exact steps to reproduce this, but my workflow files can be found here: :link:

Expected behavior

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

I expected it to move into the folder .../documentation/build then deploy as expected

Screenshots

If applicable, add screenshots to help explain your problem.

Error is same as #84 but I can provide screen shots if necessary, too.

Additional Comments

Add any other context about the problem here.

JamesIves commented 4 years ago

I cloned down your repository to test this, I think the issue is that your build script in your website directory doesn't actually build into the root directory, it goes into ../documentation/website/build.

In order to fix this can you try changing the following line to website/build? The folder is based on the root of the repository.

https://github.com/excelerondesign/documentation/blob/master/.github/workflows/main.yml#L36

Let me know if that helps!

gingerchew commented 4 years ago

Woah, thanks for the fast response! I still get a similar issue, this weird documentation//

rsync: change_dir "/home/runner/work/documentation/documentation//website/build" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
The deployment encountered an error. ❌
##[error]The process 'rsync' failed with exit code 23

I'm wondering why it inserts that unnamed directory and then looks for the website/build directory.

JamesIves commented 4 years ago

That's because actions/checkout checks out the repo into its own named directory, so that should be correct. Something seems amiss still.

Can you add the following in your build step and run it again? I want to make sure that the build directory is getting correctly generated. Once it's done running can you link me the log?

 - name: Run build command
    run: npm run build && ls
JamesIves commented 4 years ago

Aha, I think I know the issue here. This is because you have two jobs named build and deploy. You're building the site to deploy in the build job, but the deploy job is almost as-if it's a fresh start and doesn't have access to the project. If you need to build your site using a different operating system you can pass the built directory from one to another using artifacts (see docs here), but if not you can just combine the two to fix this.

name: Publish
on:
  push:
    branches:
      - master
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Set up Node
      uses: actions/setup-node@v1
      with:
        node-version: 10.x 
    - name: Set email
      run: git config --global user.email "${{ secrets.adminemail }}"
    - name: Set username
      run: git config --global user.name "${{ secrets.adminname }}"
    - name: NPM install command
      run: cd website && npm install
    - name: check package.json
      run: cat package.json
    - name: Run build command
      run: npm run build

    - name: Checkout
      uses: actions/checkout@v1

    - name: Deploy
      uses: JamesIves/github-pages-deploy-action@releases/v3
      with:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BASE_BRANCH: master
        BRANCH: gh-pages
        FOLDER: website/build

Additionally if you see the site deploy correctly but you don't see your changes you may need to use the ACCESS_TOKEN key instead: https://github.com/JamesIves/github-pages-deploy-action#configuration-

gingerchew commented 4 years ago

Hmmm, that didn't do it. The updated .yml is here

name: Publish
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Set up Node
        uses: actions/setup-node@v1
        with:
          node-version: 10.x 
      - name: Set email
        run: git config --global user.email "${{ secrets.adminemail }}"
      - name: Set username
        run: git config --global user.name "${{ secrets.adminname }}"
      - name: npm install command
        run: cd website && npm install
      - name: Run build command
        run: cd website && npm run build
      - name: Checkout
        uses: actions/checkout@v1
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_BRANCH: master
          BRANCH: gh-pages # The branch the action should deploy to.
          FOLDER: website/build # The folder the action should deploy.

I'm getting the same error with the documentation//

I don't know if this changes anything, but there is a could of lines at the end of the error message, maybe this sheds some light? Like the node run error?

rsync -q -av --progress website/build/. gh-action-temp-deployment-folder --exclude .git --exclude .github
rsync: change_dir "/home/runner/work/documentation/documentation//website/build" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1196) [sender=3.1.2]
The deployment encountered an error. ❌
##[error]The process 'rsync' failed with exit code 23
Completed Deployment ✅
##[error]Node run failed with exit code 1
gingerchew commented 4 years ago

Re: adding the ls to the build command, it is building the directory correctly

> @ build /home/runner/work/documentation/documentation/website
> docusaurus-build

generate.js triggered...
sitemap.js triggered...
Site built successfully. Generated files in 'build' folder.
README.md
build
core
i18n
node_modules
package-lock.json
package.json
pages
sidebars.json
siteConfig.js
static
JamesIves commented 4 years ago

Ah sorry, don't include the checkout step before the deploy step. Otherwise you're going to override your changes. Try this:

name: Publish
on:
  push:
    branches:
      - master
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Set up Node
        uses: actions/setup-node@v1
        with:
          node-version: 10.x 
      - name: Set email
        run: git config --global user.email "${{ secrets.adminemail }}"
      - name: Set username
        run: git config --global user.name "${{ secrets.adminname }}"
      - name: npm install command
        run: cd website && npm install
      - name: Run build command
        run: cd website && npm run build
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@releases/v3
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BASE_BRANCH: master
          BRANCH: gh-pages # The branch the action should deploy to.
          FOLDER: website/build # The folder the action should deploy.

I don't think documentation// should be an issue.

JamesIves commented 4 years ago

Just tested this again in my cloned repo. If you want the documentation files to deploy to the root you'll need to change the config so FOLDER points to website/build/documentation, or change your build script so it builds directly into the build folder.

https://github.com/JamesIves/documentation/blob/master/.github/workflows/main.yml

This will result in this: https://github.com/JamesIves/documentation/tree/gh-pages

Hope that helps!

gingerchew commented 4 years ago

I was just about to post about that, haha That was exactly the answer! thanks for all your help!