fredefox/cat

Automatically deploy clickable HTML to GitHub Pages

ayberkt opened this issue · 24 comments

As mentioned in #14, this is quite easy to do. However, an access token needs to be generated.

You can do this by navigating to GitHub settings > Developer settings > Personal access tokens. Just the public repository access privilege should be sufficient.

Then, navigate to the repository settings and then to the "Secrets" section. There you can add this as a secret, and it will be stored in an encrypted way. Then you need to pass this to the deployment action when you are calling it. Here is my workflow that does this.

Honestly, I think this is an unnecessarily cumbersome procedure. On GitLab, all of this takes literally no more than five-six lines of configuration code as their HTML hosting machinery is itself a kind of "action" and you don't need to give any access or anything like that. However, GitHub is the popular option so it's easier to just stick with it.

One thing I forgot to mention: make sure to deploy to pages only on the master branch. I forgot to do this in my own development as well. The syntax should be

on:
  push:
    branches:
      - master

I'm trying to set it up, but getting some error

  Upload HTML to Github Pages1s
    FOLDER: html
Run JamesIves/github-pages-deploy-action@releases/v3
  with:
    ACCESS_TOKEN: ***
    BRANCH: gh-pages
    FOLDER: html
Checking configuration and starting deployment… 🚦
Deploying using Access Token… 🔑

-- https://github.com/fredefox/cat/pull/16/checks?check_run_id=678494596
Unfortunately the output is a bit too terse to infer what's going wrong here...

The problem might be that you made the commits on the gh-pages branch itself. As far as I understand, this branch should be reserved for commits made by the deployment action, because it will get rid of everything and commit a bunch of HTML in there.

Actually it's on a branch named fredefox/gh-pages. It's a habit I got into of prefixing all my branches with my own username.

My token settings look like this:
image

Have you enabled GitHub Pages for the repo? First, create the gh-pages branch, and then check if GitHub Pages has been enabled for that branch.

Have you enabled GitHub Pages for the repo? First, create the gh-pages branch, and then check if GitHub Pages has been enabled for that branch.

I just tried creating a dummy GH Page document and ran the CI job again, but it's still failing :(

Let's first check if a manually committed dummy index.html on the branch gh-pages works fine.

Ah. Sorry. I was confusing Github Wiki Pages with Github Pages...

Same issue. Or at least it's giving me the same output which is unfortunately not very indicative of what's going wrong. I was able to create a Github (not-wiki) Page though: https://fredefox.github.io/cat/

Hmm, this seems bizarre. The only related issue I could find is this: JamesIves/github-pages-deploy-action#231.

As we are using almost exactly the same workflow, I don't know what might be causing this. Maybe a typo in the access token secret?

Mine is looking like this:
Screenshot from 2020-05-15 18-29-53

I tried turning debug info on and this is what is printed to the logs:


2020-05-16T11:34:46.0657910Z ##[group]Run JamesIves/github-pages-deploy-action@releases/v3
2020-05-16T11:34:46.0658364Z with:
2020-05-16T11:34:46.0658684Z   ACCESS_TOKEN: ***
2020-05-16T11:34:46.0658763Z   BRANCH: gh-pages
2020-05-16T11:34:46.0659014Z   FOLDER: html
2020-05-16T11:34:46.0659280Z ##[endgroup]
2020-05-16T11:34:46.1899409Z Checking configuration and starting deployment… 🚦
2020-05-16T11:34:46.1912285Z Deploying using Access Token… 🔑
2020-05-16T11:34:46.1914504Z Configuring git…
2020-05-16T11:34:46.1991775Z [command]/usr/bin/git init
2020-05-16T11:34:46.2084724Z Reinitialized existing Git repository in /home/runner/work/cat/cat/.git/
2020-05-16T11:34:46.2141438Z [command]/usr/bin/git config user.name fredefox
2020-05-16T11:34:46.2200441Z [command]/usr/bin/git config user.email fredefox@users.noreply.github.com
2020-05-16T11:34:46.2258537Z [command]/usr/bin/git remote rm origin
2020-05-16T11:34:46.2328556Z [command]/usr/bin/git remote add origin https://***@github.com/fredefox/cat.git
2020-05-16T11:34:46.2387925Z [command]/usr/bin/git fetch
2020-05-16T11:34:46.7365950Z From https://github.com/fredefox/cat
2020-05-16T11:34:46.7368544Z  * [new branch]      abstract-funext   -> origin/abstract-funext
2020-05-16T11:34:46.7368818Z  * [new branch]      fredefox/gh-pages -> origin/fredefox/gh-pages
2020-05-16T11:34:46.7369072Z  * [new branch]      fredefox/travis   -> origin/fredefox/travis
2020-05-16T11:34:46.7370460Z  * [new branch]      gh-pages          -> origin/gh-pages
2020-05-16T11:34:46.7370878Z  * [new branch]      master            -> origin/master
2020-05-16T11:34:46.7371101Z  * [new branch]      try-wrapped-paths -> origin/try-wrapped-paths
2020-05-16T11:34:46.7540964Z  * [new tag]         0.0.1             -> 0.0.1
2020-05-16T11:34:46.7541648Z  * [new tag]         1.0.0             -> 1.0.0
2020-05-16T11:34:46.7542171Z  * [new tag]         1.0.1             -> 1.0.1
2020-05-16T11:34:46.7542657Z  * [new tag]         1.1.0             -> 1.1.0
2020-05-16T11:34:46.7543138Z  * [new tag]         1.2.0             -> 1.2.0
2020-05-16T11:34:46.7543626Z  * [new tag]         1.3.0             -> 1.3.0
2020-05-16T11:34:46.7544107Z  * [new tag]         1.4.0             -> 1.4.0
2020-05-16T11:34:46.7544564Z  * [new tag]         1.4.1             -> 1.4.1
2020-05-16T11:34:46.7545050Z  * [new tag]         1.5.0             -> 1.5.0
2020-05-16T11:34:46.7546510Z  * [new tag]         1.6.0             -> 1.6.0
2020-05-16T11:34:46.8730768Z Fetching submodule libs/agda-stdlib
2020-05-16T11:34:47.0713083Z Fetching submodule libs/cubical
2020-05-16T11:34:47.4210696Z fatal: remote error: upload-pack: not our ref 0d3f02e68297e940227137beac45fc1bce6e2bea
2020-05-16T11:34:47.7142770Z fatal: remote error: upload-pack: not our ref 4493cf249a1648be2ad365fe94ece337bfbcb5d9
2020-05-16T11:34:47.7215624Z Errors during submodule fetch:
2020-05-16T11:34:47.7215893Z 	libs/cubical
2020-05-16T11:34:47.7216327Z 	libs/agda-stdlib
2020-05-16T11:34:47.7257861Z ##[error]There was an error initializing the repository: The process '/usr/bin/git' failed with exit code 1 ❌
2020-05-16T11:34:47.7267482Z failed
2020-05-16T11:34:47.7269681Z Deployment Failed ❌
2020-05-16T11:34:47.7272095Z ::set-env name=DEPLOYMENT_STATUS::failed

So it appears to have something to do with the submodules that I'm using. I suspect some of the github actions are messing with the git index in some way. It's kinda difficult to figure out though given that it's not happening on my machine...

Actually it's likely related to the fact that I fetch submodules using SSH. .gitmodules:

[submodule "libs/cubical"]
	path = libs/cubical
	url = git@github.com:agda/cubical.git
[submodule "libs/agda-stdlib"]
	path = libs/agda-stdlib
	url = git@github.com:agda/agda-stdlib.git

Maybe a work-around would be rewrite the URLs with:

sed -i 's%git@\([^:]*\):\(.*\)%https://\1/\2%' .gitmodules

Prior to the gh-pages action. Or somehow create SSH credentials for the thing that runs the GH actions... Not really sure how to achieve either.

Maybe a work-around would be rewrite the URLs with:

Why not just use HTTPS for the submodules instead?

In any case, I think you should report this to JamesIves/github-pages-deploy-action.

I just tried with rewriting the URLs using a sed step just before the gh action. It's giving me the same error:

fatal: remote error: upload-pack: not our ref 0d3f02e68297e940227137beac45fc1bce6e2bea
fatal: remote error: upload-pack: not our ref 4493cf249a1648be2ad365fe94ece337bfbcb5d9

I wonder what that ref is pointing to...

Why not just use HTTPS for the submodules instead?

I prefer using my SSH keyring for authentication.

I prefer using my SSH keyring for authentication.

But there is no authentication going on, is there? These are both public repositories. Not that I think it will fix the current situation as you tried rewriting.

fatal: remote error: upload-pack: not our ref 0d3f02e68297e940227137beac45fc1bce6e2bea

???

I just tried with rewriting the URLs using a sed step just before the gh action.

I suppose this confirms it is a bug in the deploy action so you should report it.

I just merged #16 but I just realized that what I really need is for the documents only to be uploaded on commits to master, but have the type-checking happen on all commits. Do you know how to do this by any chance @ayberkt ?

Thanks for your help BTW. This is a very nice change.

I just merged #16 but I just realized that what I really need is for the documents only to be uploaded on commits to master, but have the type-checking happen on all commits. Do you know how to do this by any chance @ayberkt ?

I think workflows might need to separated for that. I don't know if it is possible within a single workflow. Actually, I'm quite new to GitHub actions myself and I have yet to set up these kind of things correctly in my own developments.

Thanks for your help BTW.

Of course! I really hope more Agda people start using this action as I really like browsing Agda code in clickable HTML. I'm planning to set it up for agda/cubical when I get the time. They have an open issue on this.

By the way, you might want to use a nicer CSS for the clickable HTML. I'm not a big fan of the default one. Here's an example of how my (literate) Agda developments look like: https://ayberkt.gitlab.io/msc-thesis/CantorSpace.html. If you want to use this CSS, you can access it here.

Oooh. It's very nice with the explanatory text next to it! Is this a built-in feature of Agda or are you doing some pre-/post- processing?

Is this a built-in feature of Agda or are you doing some pre-/post- processing?

I'm just using .lagda.md files and then running them through pandoc. The Docker container I use has pandoc installed so this feature should not be too hard to add to the Agda action.