create-pull-request: Having issues creating PR on a server that is not github.com
My definitions is as follows. The repository was checked out from our enterprise github server (not github.com), so I know there’s connectivity.
- name: commit-and-push-with-pr
uses: peter-evans/create-pull-request@v5
if: ${{ inputs.create-pull-request }}
with:
token: ${{ steps.set-github-env.outputs.github_token }}
path: code
add-paths: "${{ inputs.resource-path }}/**/${{ inputs.localizable-strings-filename }} ${{ inputs.localizable-string-path }}/${{ inputs.localizable-swift-filename}}"
base: main
branch: ${{ inputs.commit-branch }}
commit-message: 'Sync ${{ github.workflow }} strings from S3'
title: 'CMS Strings update: ${{ github.workflow }}'
body: 'Sync ${{ github.workflow }} strings from S3'
I’ve validated that GITHUB_SERVER_URL is correct:
env:
GITHUB_SERVER_URL: https://github.xxxxx.com/
Yet when it comes time to push the PR it’s failing with this message:
usr/bin/git config --local --get remote.origin.url
https://github.xxxxx.com/org/repo
Error: The format of 'https://github.xxxxx.com/org/repo' is not a valid GitHub repository URL
Based on looking at utils.js, it should be picking up the GITHUB_SERVER_URL variable and validating the local git config against that, but for whatever reason it doesn’t seem to working correctly.
The same workflow works on github.com repositories, and i can commit using stefanzweifel/git-auto-commit-action@v4
for cases where the user doesn’t want a PR created, so it’s not a permissions issue.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 15 (7 by maintainers)
@peter-evans I think it differs from installation to installation, but on ours it’s at https://github.xxxxx.com/api/v3. The public github server is at https://api.github.com i believe.
I would say that you should maybe provide inputs for both of these things, and default them to $GITHUB_SERVER_URL and $GITHUB_API_URL environment variables. I’m not really sure you need to infer them.
@peter-evans That’s exactly correct. We’re facilitating a process that pulls strings files from our CMS and updates the code repositories. We made it optional to automatically create a PR, which is where your action comes in. We’re in a transition phase where some of our repos are still in GHES, but we’re moving towards GHEC. So we’d like these workflows to work for both cases.
We’re pulling code down from the repository with the actions/checkout@v3 action, passing it an explicit
token
andgithub-server-url
parameters.Then in the case where we don’t want a PR, we’re using stefanzweifel/git-auto-commit-action@v4, which uses the credentials stored with the checkout.
I think that it would be necessary to add the server-url, and token parameters (and possibly the api url if needed) to the create-pull-request task to allow it to work in this way.