Closed
Description
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 [email protected]: 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/[email protected]
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