Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a workflow to build and deploy docs site #8126

Merged
merged 5 commits into from May 22, 2020

Conversation

ashmaroli
Copy link
Member

Summary

Implement a workflow to build our documentation site with the current repository state yet served via GitHub Pages.

(Use an in-house module instead of third-party action for greater control over the process)


TODO (after the idea is accepted):

  • Add JEKYLL_PAT token (preferably get jekyllbot to step in).
  • Refactor to trigger on push event and write to gh-pages.

@ashmaroli
Copy link
Member Author

@parkr Will Jekyllbot be able to provide an access token to have GitHub Actions publish our docs site on its behalf..?

@iBug
Copy link
Contributor

iBug commented May 22, 2020

GitHub provides a GITHUB_TOKEN for each Actions run. The token has write access to the repository the workflow is running on. Is it unavailable for any reason?

Ref: https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token

@ashmaroli
Copy link
Member Author

@iBug Honestly, I didn't know about GITHUB_TOKEN.
I've updated the workflow now. Lets see if it works...

@parkr
Copy link
Member

parkr commented May 22, 2020

I think the GITHUB_TOKEN provided by Actions doesn't allow page builds to be triggered, so I'd have to add a PAT to the secrets for this repo.

@iBug
Copy link
Contributor

iBug commented May 22, 2020

@parkr This is no longer the case. I couldn't find the exact timestamp for the change but I can assure you about this. I've been building my GitHub Pages website for months without problems.

@ashmaroli Sorry I forgot to mention: The GITHUB_TOKEN secret on workflows triggered by pull requests does not have write access to the base repository (IMO this is intuitive - you don't want an arbitrary PR to be able to alter your content).

Another thing to note is that when being used to push / pull from repositories, the token must be combined with its owner (i.e. $GITHUB_ACTOR) *. Here's a working example from another project that I work on:

Code:

git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \
  "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" test

* I'm unsure if this is still a problem now, but I had problems with this in the past.

@ashmaroli
Copy link
Member Author

have to add a PAT

That's great @parkr! I think you can provide Jekyllbot's Token for security purposes.

@ashmaroli
Copy link
Member Author

you don't want an arbitrary PR to be able to alter your content

That makes sense.

@iBug
Copy link
Contributor

iBug commented May 22, 2020

Update: Here's another source stating that secrets.GITHUB_TOKEN failing trigger Pages builds has been fixed some time in February 2020. (cc @parkr)

@ashmaroli: This is a purely preferential setting. Because GITHUB_ACTOR is always set to github-actions in Actions runs, I always set the committer information to "GitHub" in my Actions workflows. For example:

git config user.name "${GIT_USER:-GitHub}"
git config user.email "${GIT_EMAIL:-noreply@github.com}"

BTW, the identity GitHub <noreply@github.com> is also the committer for all web-based Git operations (where you'll see a Verified badge that reads like following).

This commit was created on GitHub.com and signed with a verified signature using GitHub’s key.

@parkr
Copy link
Member

parkr commented May 22, 2020

I think adding a @jekyllbot PAT might be a bit scary. It's hard to lock down to a given repo. Maybe what I'll do is create a deploy key for this repo – would that work? I agree that the token should not be usable by contributors to overwrite jekyllrb.com 😱

@ashmaroli
Copy link
Member Author

I'll do is create a deploy key for this repo – would that work?

The latest run aborted with the following:

remote: Permission to jekyll/jekyll.git denied to github-actions[bot].

That could be a good sign indicating that PRs can't push to our repo.

@ashmaroli ashmaroli marked this pull request as ready for review May 22, 2020 16:40
@iBug
Copy link
Contributor

iBug commented May 22, 2020

@parkr No worries. As I said above:

The GITHUB_TOKEN secret on workflows triggered by pull requests does not have write access to the base repository

I'd say this is the best option unless you have extra requirements (authenticating another repository etc.). This special token is created every time a workflow runs and is valid for only one hour. Confident to say, GitHub has taken all the security considerations you ever need to.

Using a deploy key is definitely OK, but it adds complexity.

@ashmaroli
Copy link
Member Author

Merging this manually to master on a trial basis. Will revert if unsuccessful.

@ashmaroli ashmaroli merged commit ab8c4b9 into jekyll:master May 22, 2020
@ashmaroli ashmaroli deleted the in-house-build-action branch May 22, 2020 16:43
@iBug
Copy link
Contributor

iBug commented May 22, 2020

on a trial basis

@ashmaroli You need not. Merging this into another branch is also OK as long as it's in the target repository.

ashmaroli added a commit that referenced this pull request May 22, 2020
This reverts commit ab8c4b9
and commit 5e2af1b
@iBug
Copy link
Contributor

iBug commented May 22, 2020

@ashmaroli I just tested in my repository, specifying the user as x-access-token leads to failure.

Use the following URL for the remote repository, however, succeeded used to succeed.

"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"

Update

Things are getting nasty now. My repositories are also failing to push with GITHUB_TOKEN, where all of them were working properly (even yesterday). This looks more like an issue on GitHub's side.

Looks like it's related to this issue: https://www.githubstatus.com/incidents/6tcfpztf6j9m

@ashmaroli
Copy link
Member Author

@iBug and was ${GITHUB_ACTOR} your username?

@iBug
Copy link
Contributor

iBug commented May 22, 2020

@ashmaroli ${GITHUB_ACTOR} has consistently been github-actions in my Actions runs.

Sorry I was wrong. ${GITHUB_ACTOR} is my username (iBug).

See the update in the above comment. I'm currently waiting for the GitHub problem to resolve. I think it's the cause of the push failure.


Anyway, I'm going to sleep now (1:20 AM in UTC+8). Hope things will be settled when I wake up.

@jekyll jekyll locked and limited conversation to collaborators May 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants