diff --git a/Dockerfile b/Dockerfile index 38753f7..89546ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" @@ -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"] diff --git a/action.yml b/action.yml index 71ed9eb..914926e 100644 --- a/action.yml +++ b/action.yml @@ -22,3 +22,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 diff --git a/entrypoint.sh b/entrypoint.sh index c5268c0..51e547d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,25 +5,35 @@ 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 git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" 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 πŸŽ‰πŸŽ‰ πŸ•ΊπŸ’ƒ '