Skip to content

Commit

Permalink
Merge pull request #9 from josemlp91/master
Browse files Browse the repository at this point in the history
Node Modules support
  • Loading branch information
nelsonjchen authored May 2, 2021
2 parents a115789 + 2bc7009 commit 893b835
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
9 changes: 8 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7
FROM python:3.7-slim

LABEL "com.github.actions.name"="Pelican for GitHub Pages"
LABEL "com.github.actions.description"="Builds and deploys the Pelican project to GitHub Pages"
Expand All @@ -12,6 +12,13 @@ ENV LC_ALL C.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

RUN apt-get update \
&& apt-get install --no-install-recommends -qy git curl bash


RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get install -y nodejs

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ in the virtual environment your pelican site is developed in.
- `GH_PAGES_BRANCH` (optional): override the default `gh-pages` deployment branch
- `GH_PAGES_CNAME` (optional): specify the custom domain you've configured (if any)
- `PELICAN_CONFIG_FILE` (optional): override the default `pelicanconf.py` config file
- `PELICAN_CONTENT_FOLDER` (optional): 'override the default `content` content folder'
- `PELICAN_CONTENT_FOLDER` (optional): override the default `content` content folder
- `PELICAN_THEME_FOLDER` (optional): setup the theme folder with `package.json` file, it is required if you need install node modules.
- `GITHUB_TOKEN`: (required) should be `${{secrets.GITHUB_TOKEN}}`, see [the workflow demo in the demo repository for an example of this][workflow_demo]. This secret is fulfilled by GitHub.

## Demo
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ inputs:
description: 'override the default `content` content folder'
required: false
default: content
PELICAN_THEME_FOLDER:
description: 'setup the theme folder with package.json file, is required if you need install node modules'
required: false
32 changes: 21 additions & 11 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ set -e
echo "REPO: $GITHUB_REPOSITORY"
echo "ACTOR: $GITHUB_ACTOR"

echo '=================== Install Requirements ==================='
pip install -r requirements.txt
echo '=================== Build site ==================='
pelican ${PELICAN_CONTENT_FOLDER:=content} -o output -s ${PELICAN_CONFIG_FILE:=pelicanconf.py}
echo '=================== Publish to GitHub Pages ==================='
cd output
# shellcheck disable=SC2012
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_branch=${GH_PAGES_BRANCH:=gh-pages}

echo 'Installing Python Requirements 🐍 '
pip install -r requirements.txt

if [ -n "$PELICAN_THEME_FOLDER" ]; then
echo 'Installing Node Modules 🧰 '
pushd $PELICAN_THEME_FOLDER
npm install
popd
fi

echo 'Building site 👷 '
pelican ${PELICAN_CONTENT_FOLDER:=content} -o output -s ${PELICAN_CONFIG_FILE:=pelicanconf.py}

echo 'Publishing to GitHub Pages 📤 '
pushd output
git init
git remote add deploy "$remote_repo"
git checkout $remote_branch || git checkout --orphan $remote_branch
Expand All @@ -24,10 +33,11 @@ then
echo "$GH_PAGES_CNAME" > CNAME
fi
git add .

echo -n 'Files to Commit:' && ls -l | wc -l
timestamp=$(date +%s%3N)
git commit -m "[ci skip] Automated deployment to GitHub Pages on $timestamp"
git commit -m "[ci skip] Automated deployment to GitHub Pages on $(date +%s%3N)"
git push deploy $remote_branch --force
rm -fr .git
cd ../
echo '=================== Done ==================='
popd

echo 'Done 🎉🎉 🕺💃 '

0 comments on commit 893b835

Please sign in to comment.