I want to create a GitHub Action for my private repository (repo A
) that does the following:
- Check out a private repository (
repo A
) - Check out a public repository (
repo B
) - Cleanup subfolder
bob
ofrepo B
- Copy contents of subfolder
repo A/alice
torepo B/bob
- Push the change as a commit to
repo B
Both are repositories from the same organization. I deployed a key pair (ACTIONS_SECRET
) in the settings of my private repository like described in this answer. My current action looks like this:
name: Publish docsify
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout alice
uses: actions/checkout@v3
with:
path: alice
- name: Checkout bob
uses: actions/checkout@v3
with:
repository: <org/repo B>
ssh-key: ${{ secrets.ACTIONS_SECRET }}
ref: main
path: bob
- name: Cleanup
run: |
pushd bob
git rm -rf .
popd
- name: Copy alice
run: |
pushd bob
cp -rvf ../alice/* .
popd
ls -la bob/
- name: Publish
run: |
eval `ssh-agent -s`
ssh-add - <<< '${{ secrets.ACTIONS_SECRET }}'
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "github-actions"
pushd bob
git add .
git commit -m "Build from Action ${GITHUB_SHA}"
git push origin main
popd
The action fails at the Publish
step with the following error:
ERROR: Permission to <repo B> denied to deploy key
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: Process completed with exit code 128.
This is my first action and I don't know how to solve this error. Please help.