-
Notifications
You must be signed in to change notification settings - Fork 2
Description
I use the action in a workflow job, where the result (a value) of a previous job is committed to a file in a remote repository. The repository of the workflow is not related to the remote repository at all (eg. one is not a fork of the other etc.).
The workflow looks like this:
name: Example workflow with remote repository
jobs:
<multiple previous jobs>
update-remote-repos:
name: Update remote repository
needs: <previous job>
runs-on: ubuntu-latest
steps:
- name: Checkout remote repository
uses: actions/checkout@v3
with:
repository: user/remote-repository
token: ${{ secrets.PAT }}
ref: some-branch
- name: Update some file
run: <modify ./some/file.dat>
- Commit & push changes to remote repository
uses: GuillaumeFalourd/git-commit-push@v1
with:
target_branch: some-branch
file: ./some/file.dat
access_token: ${{ secrets.PAT }}
The action will fail in case the workflow is triggered by a branch (eg. main) that does not exist in the remote repository - in the example above the job operating on the remote repository is working on a branch called some-branch, and let's assume that's the only branch of that repository.
Specifically the git fetch command will fail
Line 92 in 80a3d07
| git fetch "${{ inputs.remote_repository }}" "$CURRENT_BRANCH" |
as the script assumes the branch that triggered the workflow run is the current branch of the remote repository:
Line 58 in 80a3d07
| CURRENT_BRANCH=${GITHUB_REF} |
In other words, the script does not respect the branch that was specified during checkout of a remote repository using actions/checkout.