Failure on copyAssets when using external_repository, publish_dir and destination_dir
DerAndereAndi opened this issue ยท 8 comments
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
- Set up an action with the configuration shown below
- Run with the remote repository not having a
main
branch - 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:
actions-gh-pages/src/git-utils.ts
Line 24 in 09b03c0
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?
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.
Please let me know if there is anything else I can do to help
Looking at the code it seems to be using the NodeJS 12 default copyFileSync
method. 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?
#414 seems to fix this issue. Please check the latest deployment I triggered on your private repository.
Yep, it works. Thank you!!!!
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. ๐