Initial test

This commit is contained in:
justgoodin 2021-06-27 01:00:30 +05:30
commit fd73720769
2 changed files with 66 additions and 0 deletions

24
Dockerfile Normal file
View file

@ -0,0 +1,24 @@
FROM python:3.9-slim
LABEL "com.github.actions.name"="Deploy Pelican Site to Firebase"
LABEL "com.github.actions.description"="Deploy Pelican Site to Firebase"
LABEL "com.github.actions.icon"="mic"
LABEL "com.github.actions.color"="yellow"
LABEL "repository"="https://github.com/justgoodin/pelican-to-firebase"
LABEL "homepage"="https://github.com/justgoodin/pelican-to-firebase"
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"]

42
entrypoint.sh Normal file
View file

@ -0,0 +1,42 @@
#!/bin/bash
set -e
echo "REPO: $GITHUB_REPOSITORY"
echo "ACTOR: $GITHUB_ACTOR"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
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"
if [ "$GH_PAGES_CNAME" == "none" ]
then
echo "$GH_PAGES_CNAME" > CNAME
fi
git add .
echo -n 'Files to Commit:' && ls -l | wc -l
git commit -m "[ci skip] Automated deployment to GitHub Pages on $(date +%s%3N)"
git push deploy $remote_branch --force
rm -fr .git
popd
echo 'Done 🎉🎉 🕺💃 '