peaceiris / actions-gh-pages

GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.
https://github.com/marketplace/actions/github-pages-action
MIT License
4.55k stars 364 forks source link

Github Enterprise Compatibility #579

Open ghost opened 3 years ago

ghost commented 3 years ago

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.

peaceiris commented 3 years ago

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 commented 3 years ago

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`;
mambax commented 3 years ago

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!?

peaceiris commented 3 years ago

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

mambax commented 3 years ago

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

On it, expect PR 🔄

peaceiris commented 3 years ago

We can test #580 with 3623583f73a5cfb5ca3632d6234b9564fed73239

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

I can do that today!

peaceiris commented 3 years ago

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

mambax commented 3 years ago

image image

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

peaceiris commented 3 years ago

@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.

jiminj commented 2 years ago

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?