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

Failure on copyAssets when using external_repository, publish_dir and destination_dir #410

Closed
DerAndereAndi opened this issue Jul 23, 2020 · 8 comments · Fixed by #414
Closed
Assignees
Labels
bug Something isn't working resolved stale

Comments

@DerAndereAndi
Copy link
Contributor

Describe the bug

I am trying to publish a subdirectories content on a given branch on a private repository A onto a remote private repository B into a subfolder. The process fails with an error when the branch already exists with content. It works when the branch does not exist yet.

The reason for this setup is, the generated website will not be hosted via gh-pages on Github but being uploaded to a remote server from the remote private repository B using Github Actions and SamKirkland/FTP-Deploy-Action.

  • So we have the hugo source in repository A
  • On Repository A we build using github actions and push the generated page to repository B
  • On Repository B another github action is now running pushing the generated page via SFTP to the final server
  • This way it is possible to only upload the changed pages instead of upload everything over and over again (>800 generated pages)

To Reproduce

  1. Set up an action with the configuration shown below
  2. Run with the remote repository not having a main branch
  3. Run again and receiving a failure.
 ##[group]Prepare publishing assets
 [INFO] ForceOrphan: false
 [command]/usr/bin/git clone --depth=1 --single-branch --branch automated git@github.com: username/deploy-staging.git /home/runner/actions_github_pages_1595511235704
 Cloning into '/home/runner/actions_github_pages_1595511235704'...
 [INFO] clean up /home/runner/actions_github_pages_1595511235704/public
 [command]/usr/bin/git rm -r --ignore-unmatch *
 rm 'public/404.html'
 rm 'public/...'
 [INFO] first deployment, create new branch automated
 EISDIR: illegal operation on a directory, copyfile '/home/runner/work/username/sourcerepository/public/404.html' -> '/home/runner/actions_github_pages_1595511235704/public/'
 [command]/usr/bin/git init
 Reinitialized existing Git repository in /home/runner/actions_github_pages_1595511235704/.git/
 [command]/usr/bin/git checkout --orphan automated
 fatal: A branch named 'automated' already exists.
 ##[error]Action failed with "The process '/usr/bin/git' failed with exit code 128"

Expected behavior

The copy files process to the empty destination repository should not fail.

Your YAML file

name: staging deploy

on:
  push:
    branches:
      - develop

jobs:
  deploy:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
        with:
          ref: develop
          submodules: true  # Fetch Hugo themes (true OR recursive)

      - name: setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: '0.74.1'

      - name: build
        run: hugo -D --minify -v

      - name: deploy to staging repo
        uses: peaceiris/actions-gh-pages@v3.7.0-1
        with:
          deploy_key: ${{ secrets.STAGING_DEPLOY_KEY }}
          external_repository: username/deploy-staging
          publish_branch: main
          publish_dir: ./public
          destination_dir: public
          allow_empty_commit: false
          commit_message: ${{ github.event.head_commit.message }}

Additional context

The error is thrown here:

await io.cp(filePath, `${destDir}/`, copyOpts);

@peaceiris
Copy link
Owner

Thank you for your feedback on this beta feature!

EISDIR: illegal operation on a directory, copyfile '/home/runner/work/username/sourcerepository/public/404.html' -> '/home/runner/actions_github_pages_1595511235704/public/'

I am trying to reproduce this error but I have not caught it yet. (Deploy from peaceiris/hugo-test-project to peaceiris/test-hugo-external-repo)

Could you share a minimal test set? Or, could you recreate your environment on peaceiris/hugo-test-project?

@DerAndereAndi
Copy link
Contributor Author

Hi there and thanks for all the actions and the quick feedback.

I was able to reproduce the problem on two private repositories I created with a blank new hugo site. I'd be happy to invite you to both so you can check it out and get your hands on them.

@DerAndereAndi
Copy link
Contributor Author

Please let me know if there is anything else I can do to help

@DerAndereAndi
Copy link
Contributor Author

Looking at the code it seems to be using the NodeJS 12 default copyFileSyncmethod. According to the documentation https://nodejs.org/dist/latest-v12.x/docs/api/fs.html#fs_fs_copyfilesync_src_dest_flags it requires the destination to have the full destination, including the target folder and filename. Right now only the target folder is provided.

So I assume (haven't tested it) the code in https://github.com/peaceiris/actions-gh-pages/blob/main/src/git-utils.ts#L23 should be done for the target directory.

So the code in there should look like

    const filePublishPath = path.join(publishDir, file);
    const fileDestPath = path.join(destDir, file);
    await io.cp(filePublishPath, ${fileDestPath}, copyOpts);

Could this be?

@peaceiris
Copy link
Owner

#414 seems to fix this issue. Please check the latest deployment I triggered on your private repository.

@DerAndereAndi
Copy link
Contributor Author

Yep, it works. Thank you!!!!

@peaceiris
Copy link
Owner

I really appreciate what you've done! After adding some tests and refactoring, the v3.7.0 will be released. Until then, we can use v3.7.0-4.
Thank you very much. 😄

@github-actions
Copy link
Contributor

This issue has been LOCKED because of it being resolved!

The issue has been fixed and is therefore considered resolved.
If you still encounter this or it has changed, open a new issue instead of responding to solved ones.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working resolved stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants