actions-gh-pages icon indicating copy to clipboard operation
actions-gh-pages copied to clipboard

Github Enterprise Compatibility

Open ghost opened this issue 3 years ago • 11 comments

I can not find an option (a clean one) that allows to set the Server URL or Api Url and they seem to be hardcoded to github.com.

Prepare publishing assets
  [INFO] ForceOrphan: false
  /usr/bin/git clone --depth=1 --single-branch --branch gh-pages ***github.com/coresystemsFSM/blog.git /home/runners/actions_github_pages_1615224725805
  Cloning into '/home/runners/actions_github_pages_1615224725805'...
  remote: Invalid username or password.
  fatal: Authentication failed for 'https://github.com/coresystemsFSM/blog.git/'

This fails because our repo is at https://github.tools.sap/coresystemsFSM/blog

As we want to use your action with GitHub Enterprise we would need to be able to customise those.

Link to your contents

I see one entry here but I think its unused during a workflow. https://github.com/peaceiris/actions-gh-pages/blob/c1c219f526155987550e06bedfcc8e2fcc34f19b/Dockerfile#L36

Additional context

I would contribute a PR if you give me 1-2 pointers where I'd need to add things in your structure.

ghost avatar Mar 08 '21 17:03 ghost

Since I have no environment of GitHub Enterprise Server, I was looking forward to this issue, thanks!

https://github.com/peaceiris/actions-gh-pages/blob/a0db9b66be08f409f8263ee57ca1dd625d9f0b59/src/set-tokens.ts#L66

We can modify the function setGithubToken to get a server domain from process.env['GITHUB_SERVER_URL'].

peaceiris avatar Mar 08 '21 18:03 peaceiris

  • https://github.com/actions/checkout/blob/25a956c84d5dd820d28caab9f86b8d183aeeff3d/src/url-helper.ts#L22
  • https://github.com/actions/checkout/blob/25a956c84d5dd820d28caab9f86b8d183aeeff3d/src/git-auth-helper.ts#L54

Those are also helpful for us.

export function getServerUrl(): URL {
  // todo: remove GITHUB_URL after support for GHES Alpha is no longer needed
  return new URL(
    process.env['GITHUB_SERVER_URL'] ||
      process.env['GITHUB_URL'] ||
      'https://github.com'
  )
}
const serverUrl = getServerUrl()

return `https://x-access-token:${githubToken}@${serverUrl.hostname}/${publishRepo}.git`;

peaceiris avatar Mar 08 '21 18:03 peaceiris

Should we read the ENV variable or should it be handed into the action by an input? I can PR both, what is the better design - I am a novice!?

mambax avatar Mar 08 '21 19:03 mambax

The former is the best because GITHUB_SERVER_URL can provide a URL of a company's GitHub Enterprise Server.

peaceiris avatar Mar 08 '21 19:03 peaceiris

The former is the best because GITHUB_SERVER_URL can provide a URL of a company's GitHub Enterprise Server.

On it, expect PR 🔄

mambax avatar Mar 09 '21 07:03 mambax

We can test #580 with 3623583f73a5cfb5ca3632d6234b9564fed73239

- name: Deploy
  uses: peaceiris/actions-gh-pages@3623583f73a5cfb5ca3632d6234b9564fed73239
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    publish_dir: ./public

peaceiris avatar Mar 10 '21 03:03 peaceiris

I can do that today!

mambax avatar Mar 10 '21 05:03 mambax

github_token and personal_token look good to me, it also works well on github.com. I will work on SSH implementation on #581

peaceiris avatar Mar 10 '21 06:03 peaceiris

image image

I would say: ⭐️⭐️⭐️⭐️⭐️

mambax avatar Mar 10 '21 06:03 mambax

@dominikmeyersap Could you try v3.8.0?

The release v3.8.0 has capability of deployment with github_token and personal_token, excluding deploy_key. The SSH option for GitHub Enterprise will be implemented in the next release.

  • [ ] TODO: https://github.com/actions/toolkit/pull/794/files

peaceiris avatar Mar 25 '21 13:03 peaceiris

I am running this action on a self-hosted runner dedicated to a GHES repository, and seeking a way to publish the pages to an external repository on github.com to deliver documents for our customers. The issue is, the current implementation is not applicable for this kind of usages.

export function getServerUrl(): URL {
  return new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
}

There should be a few ideas to resolve this. One approach I can imagine is introducing an optional parameter such as host (or external_host, whatever) which allows users to designate GitHub host URL. Another idea is to let external_repository env variable accept the repository address with a hostname, such as github.com/peaceiris/actions-gh-pages or github.com:peaceiris/actions-gh-pages. Any thoughts?

jiminj avatar Dec 14 '21 07:12 jiminj