Comments (14)
Did you try https://x-access-token:<GITHUB_TOKEN>@github.com/owner/repo.git
? I’ve heard that worked for others to push updates to the repository from an action, but didn’t use it myself yet.
See https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#http-based-git-access-by-an-installation - I know this is for installations, but I think actions are sharing some implementation logic or something
from ghpages.
We’ve found that using a repository deployment key and using an ssh remote also works and is safer since it’s scoped to the repo only.
from ghpages.
@maxheld83 Thanks for documenting this I spent a ton of time trying to figure out why my environment was not building!
from ghpages.
I just tested it and it works: https://github.com/gr2m/ghpages/tree/gh-pages
Pull request incoming
from ghpages.
👋 @maxheld83 - there is indeed a difference of behavior when using Personal Access Tokens and OAuth Tokens, which the GITHUB_TOKEN
is. In my experience, the difference actually only happen on public repos. Pages publishing works fine on private repos, which is ironic as the Pages site is always public anyway.
I'm planning on investigating this deeper but I'm afraid this is not on top of todo list.
from ghpages.
repo
from ghpages.
@maxheld83 Yes that's correct. In fact this is what I explicitly mention in the README.
I'm not sure if this behaviour is different for private repos but I'd probably say it isn't.
For posterity this is the complete explanation I got from the Github Staff:
I see that you're using the GITHUB_TOKEN environment variable to authenticate. That variable is a GitHub App installation token (also known as a server-to-server installation token).
After speaking with the team about this, they let me know that server-to-server requests won't kick off a page build, whether it's creating a commit or explicitly requesting a page build:
I see how it would be useful to open this functionality to GitHub Actions, so I've let the team know about this internally.
However, I'd like to mention that the requesting a page build endpoint is enabled for integrations via a user access token. In other words, you can make a user-to-server request to request a page build:
Alternatively, you can create a personal access token and use that to request a page build:
from ghpages.
from gh:
Currently, using an installation token to make a server-to-server request won't kick off a page build, whether it's creating a commit or explicitly requesting a page build.
However, I'd like to mention that the requesting a page build endpoint is enabled for integrations via a user access token. More specifically, you can create a personal access token and use that instead of the installation token to push a commit or request a page build:
https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line
my response / latest experience:
I did just build a github action for vanilla (= no static site building included) gh pages deployment: https://github.com/maxheld83/ghaction-ghpages
It took me a while to understand what you had already warned about; that
GITHUB_TOKEN
wouldn't trigger a page build.I now got this to work with a normal Github PAT, just like we used to do it in the old Travis days :/.
I was initially confused because I never really needed GitHub to start a (Jekyll) build, but just serve whatever was up on my gh-pages branch. But I guess for the GitHub webserver to kick in and update, the same conditions have to be met.
It'd be great if you guys could lift this limitation of the GITHUB_TOKEN soon, or provide some other way to seamlessly deploy to GitHub pages.
Not having to deal with this kind of manual auth via PATs was a big draw for me to use gh actions in the first place, and having
GITHUB_TOKEN
auth a git push to gh-pages branch, but not triggering the downstream update of the gh webserver is really counterintuitive.I'll write something up on my action tomorrow to prevent others from stumbling into this issue as well.
cheers: Max
from ghpages.
@helaili @BryanSchuetz @shalzz you guys also seemed to have implemented deploying assets to github pages from within GitHub actions (in fact, I stole your git incantations).
I noticed that you guys also used GITHUB_TOKEN
as a secret, though I now understand that the default GITHUB_TOKEN
that comes with github actions does not suffice to trigger an update to the github webserver, even though it does suffice to push to the gh-pages
branch.
I only got it to work once I provisioned a bespoke GitHub PAT for this purpose, and passed that as a secret.
Did I get this right? Did you face the same limitation as well?
from ghpages.
As @helaili mentions—using GITHUB_TOKEN
to kick off a pages build seems to work fine in private repositories—at least it has for me. I haven't really dug into the documentation much, but I wonder if the problem you're seeing might simply be a function of the currently limited beta?
GitHub Actions is limited to private repositories and push events in public repositories during the limited public beta.
from ghpages.
@gr2m I didn't get to give that a go. I will definitely give that a go in the next few weeks!
from ghpages.
Thanks @gr2m this works great!
This appears to work but the environment does not build on deployment, you can read more here: #18
from ghpages.
What kind of permissions does the PAT need in order to be able to push? There is no checkbox there that says "push_rights".
from ghpages.
closing this in favor of #18
from ghpages.
Related Issues (20)
- alloy deploy to master branch /docs/
- Does not work with the root directory (BUILD_DIR = /.) HOT 5
- Return neutral code when nothing to commit HOT 1
- run integration test HOT 2
- automatically prevent infinite loops HOT 3
- CNAME file
- maybe merge with other ghpages? HOT 1
- add better name to listing
- release and hard-code git version in documentation
- migrate to a node.js action HOT 4
- document minimum required scope for PAT
- Heartbeat HOT 1
- deployment overwrites my master branch with the build
- Consider creating a `.nojekyll` file
- add new metadata
- migrate to new yaml metadata
- Fatal: Could not read Username for "https://github.com", No such device or address
- add branch deploy
- use GITHUB_TOKEN HOT 1
- GitHub default branch name is main
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ghpages.