-
Notifications
You must be signed in to change notification settings - Fork 32
Replace GH_PAT with built-in GITHUB_TOKEN #18
base: master
Are you sure you want to change the base?
Conversation
This is really awesome, thanks @gr2m for sharing this solution!! |
Use this: That will use |
Demonstration of the above
|
Thanks Patrik, it’s a little more complicated, because the URL schema changes. if REMOTE_REPO="https://${GH_PAT}@github.com/${GITHUB_REPOSITORY}.git" && \ if
|
@gr2m True, I missed that. What do you think of this?
|
(It is |
Thanks Patrik! I’ve done the change via e8abdfe. Does that the script look good to you now? |
Yes! |
this amazing @dentarg and @gr2m, thanks for the thorough work! This would make it so much easier to use. I want to merge this asap, but just want to be sure this is officially supported by GitHub actions, because I was told a while back (as per #1 and on a call with the actions team) that this (not accepting I'm also unfortunately not familiar with the Unless there's some kind of documentation on GitHub actions that this is an intended feature, I'd like to quickly reach out to GH actions support and have them look over the PR if that's alright with you @gr2m. They've been super responsive and helpful so far. |
I'm using Found the following page via a quick web search I did now: https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation Could |
@JasonEtco told me about the Let me reach out and see if we can get a statement from the GitHub Actions team on wether using |
great, thanks @gr2m. Can you post your support query and response here or in #1? |
So far all we heard was "we don’t want to promise anything", I’ll contact support next as they will follow up. But I think that even if it changes, it wouldn’t be too hard to support both URL schemas: with and without the |
@gr2m @maxheld83 this is working for authentication and pushing to the Latest environment build is 26 days ago, it is not deploying the new changes: Latest changes today in @gr2m can you confirm this is triggering a deployment to GitHub pages? My gut feeling is that is not. Talking to support they told me this:
|
Ouch, that is a deal breaker. I am sorry, I did not catch that. I knew the |
The GitHub Actions docs for GitHub token secret says the |
I’ve added a Could someone test this out? I’m a little under water |
entrypoint.sh
Outdated
@@ -27,6 +28,7 @@ fi && \ | |||
git add . && \ | |||
git commit -m 'Deploy to GitHub pages' && \ | |||
git push --force $REMOTE_REPO master:$REMOTE_BRANCH && \ | |||
curl -XPOST -H"Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds && \ # https://git.io/fjsFk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this API is in the preview period, it requires to specify a custom media type in the Accept
header:
-H"Accept: application/vnd.github.mister-fantastic-preview+json"
Just wanted to circle back here and let you know we recently moved the underlying Pages app to use GitHub App tokens, so the change in this PR to use the Actions One thing I also wanted to point out is newer users need to include the user ID before the # https://developer.github.com/v3/activity/events/types/#pushevent
"pusher": {
"name": "Codertocat",
"email": "[email protected]"
}, Then you always get the verified e-mail of the pusher or their noreply, depending on their configuration. Haven't tested this, but I think that should work in Actions v2 as well. |
@tcbyrd This still appears to be an issue, I'm able to push the commits via the github token using the |
@JamesIves I was testing this last night in one of my repos and had it working with the |
@tcbyrd Yeah, still seeing it. It pushes the commits up to the gh-pages branch and it still doesn't seem to trigger the re-build with Here's a repo that uses an action that performs a similar task as the ones proposed in this PR incase that's helpful: https://github.com/JamesIves/reddit-viewer/commit/e269ce2270888eabfc35c91e75ea5582ec0f2534/checks Is the post request to the pages API necessary for this to work, or should it trigger the re-build without that step? |
Interesting. I can see it's still getting the same error, as if it's not using the app token yet even though it clearly should be. Let me double check a few things. |
@tcbyrd Any updates on this? |
…m/ghpages-1 in order to try out whether this pull request works for me: maxheld83/ghpages#18
Did anyone try to use the Request a page build API after pushing? Will that work @tcbyrd? |
I didn't know this existed. I will give this a go this week. Thanks @gr2m. |
Yeh that will work, but there's a caveat. One of the issues I realized the other day was that a user has to be an admin on a repository in order to create/publish the initial Pages site. Since the Actions token does not have admin permissions on the repository, it can't create Pages sites from scratch, but it can push new contents to an existing Pages branch. |
@tcbyrd @gr2m this unfortunately doesn't work. @dahlia pointed out above that using the
I could replicate this in my own action:
https://github.com/alex-page/alex-page/commit/1b894e9a0e3d549069e6ad148f432968fb6f2978/checks Here is the code I am using to hit the endpoint: It would be great if that endpoint got opened up to the |
why isnt this merged? this is totally the solution, i would like to just add this action to my workflow, and set the |
sorry about the hold-up; I was still hoping for a non-beta-y way to publish, because I don't want this to break sometime down the road. Also: if I see this right, the present version of the PR would require Lastly, this is probably superseded by #23, which makes this a pure JS action, no docker needed. Should be much faster. |
This isn't working as of right now. There are some problems using
|
the error only happens because it is still making the curl request to start a page build, but i have been testing, and looks like they did fix pushing from an action starting the build. because it works for me if i remove that line (and actually serves the newly built / deployed site) |
The latest I heard is that only the first build of GitHub Pages needs to happen by an admin. After that pushing to |
maybe it could have a notice that while the actions feature is still in beta, this action is not able to do the initial deploy, and could possibly give the steps for beginners to do that initial deploy, if done using
i could submit a PR with something like that added to the readme if it would help? |
that would be great @jstacoder As I mentioned, I also want to merge @alex-page's migration of this to a JavaScript-based action asap; the auth issues should remain the same, but the whole thing will become much leaner (no more docker). Also, JS actions support input and output arguments more easily, and because it's not limited to bash, nicer control logic, so if we want to take care of these edge cases here (fallback option, 1st commit from admin), that might be helpful as well. |
@maxheld83 since actions support versions, and the change from @alex-page is going to be a big move from the current implementation maybe it would be best to merge things piece by piece to keep the versions, since its currently at v0.2.1 maybe this PR and an updated readme could be v0.2.2 and v0.2.3 and then the big change could be v1.0.0, then it has the clear history and people that can use it now can, and we wont have to point to commits or branches (which can be done in place of a version) i dont mean to be a pest about this, but i would love to have a clean solution, (that isnt handrolled) even if it means a slower docker version of it. |
this repo has a great solution, (albeit still using docker): https://github.com/ad-m/github-push-action/blob/master/start.sh |
closes #1, closes #17. Tested on https://github.com/gr2m/ghpages