Skip to content

Commit

Permalink
Merge pull request #6 from nelsonjchen/token-http
Browse files Browse the repository at this point in the history
Use GITHUB_TOKEN through HTTP to push
  • Loading branch information
nelsonjchen authored Feb 14, 2020
2 parents 12f9bb5 + 03e11b6 commit aa6f771
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ This action builds a Pelican project and deploys it to GitHub Pages.
Please ensure a `requirements.txt` is present for your site and installs
`pelican` and other requirements needed to build your site.

## Secrets

- `GIT_DEPLOY_KEY`: provide a SSH private key for a [deploy key][1]
- This is an alternative to `GITHUB_TOKEN` [which currently can't build pages][gt_limit].
- Personal Access Tokens are not desired either since they grant access to your
*whole* account.
A `requirements.txt` can be generated by running `pip freeze > requirements.txt`
in the virtual environment your pelican site is developed in.

## Environment variables

- `GH_PAGES_BRANCH` (optional): override the default `gh-pages` deployment branch
- `PELICAN_CONFIG_FILE` (optional): override the default `pelicanconf.py` config file

## Demo

Repository: https://github.com/nelsonjchen/pelican-action-demo

Website: https://pelican-action-demo.mindflakes.com/

## History

Extracted from https://github.com/desertpy/desertpy-pelican.
Expand All @@ -25,5 +27,3 @@ It is not used there anymore though. For most sites though, this should
suffice.

[1]: https://developer.github.com/v3/guides/managing-deploy-keys/#deploy-keys

[gt_limit]: https://github.com/maxheld83/ghpages/pull/18#issuecomment-485274829
16 changes: 16 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: GitHub Pages Pelican Build Action
description: This action builds a Pelican project and deploys it to GitHub Pages.

runs:
using: 'docker'
image: 'Dockerfile'

inputs:
GH_PAGES_BRANCH:
description: 'override the default `gh-pages` deployment branch'
required: false
default: 'gh-pages'
PELICAN_CONFIG_FILE:
description: 'override the default `pelicanconf.py` config file'
required: false
default: pelicanconf.py
7 changes: 1 addition & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,12 @@ echo "ACTOR: $GITHUB_ACTOR"

echo '=================== Install Requirements ==================='
pip install -r requirements.txt
echo '=================== Create deploy key to push ==================='
mkdir /root/.ssh
ssh-keyscan -t rsa github.com > /root/.ssh/known_hosts && \
echo "${GIT_DEPLOY_KEY}" > /root/.ssh/id_rsa && \
chmod 400 /root/.ssh/id_rsa
echo '=================== Build site ==================='
pelican content -o output -s ${PELICAN_CONFIG_FILE:=pelicanconf.py}
echo '=================== Publish to GitHub Pages ==================='
cd output
# shellcheck disable=SC2012
remote_repo="git@github.com:${GITHUB_REPOSITORY}.git"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_branch=${GH_PAGES_BRANCH:=gh-pages}
git init
git remote add deploy "$remote_repo"
Expand Down

0 comments on commit aa6f771

Please sign in to comment.