chore(post): Remove draft post #169
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- master | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
Build: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_BRANCH: gh-pages | |
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }} | |
HUGO_VERSION: "0.148.2" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Hugo | |
run: | | |
echo '=================== Install Hugo ===================' | |
DOWNLOAD_HUGO_VERSION=${HUGO_VERSION:-0.110.0} | |
GITHUB_DEPLOY_REPOSITORY=${GITHUB_REMOTE_REPOSITORY:-$GITHUB_REPOSITORY} | |
GITHUB_DEPLOY_BRANCH=${GITHUB_BRANCH:-"gh-pages"} | |
echo "Installing Hugo $DOWNLOAD_HUGO_VERSION" | |
wget -O /tmp/hugo.tar.gz https://github.com/gohugoio/hugo/releases/download/v${DOWNLOAD_HUGO_VERSION}/hugo_extended_${DOWNLOAD_HUGO_VERSION}_Linux-64bit.tar.gz &&\ | |
tar -zxf /tmp/hugo.tar.gz -C /tmp &&\ | |
mv /tmp/hugo /usr/local/bin/hugo | |
echo '=================== Create deploy key to push ===================' | |
mkdir -p ~/.ssh/ | |
echo "${{ secrets.GIT_DEPLOY_KEY }}" > ~/.ssh/github_actions | |
chmod 400 ~/.ssh/github_actions | |
eval `ssh-agent -s` | |
ssh-add ~/.ssh/github_actions | |
echo '=================== Update all submodules ===================' | |
git submodule init | |
git submodule update --recursive --remote | |
echo '=================== Build site ===================' | |
HUGO_ENV=production hugo --minify -d dist | |
echo '=================== Publish to GitHub Pages ===================' | |
cd dist | |
remote_repo="git@github.com:${GITHUB_DEPLOY_REPOSITORY}.git" && \ | |
remote_branch=${GITHUB_DEPLOY_BRANCH} && \ | |
echo "Pushing Builds to $remote_repo:$remote_branch" && \ | |
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 "Automated deployment to GitHub Pages on $timestamp" > /dev/null 2>&1 && \ | |
git push deploy $remote_branch --force && \ | |
rm -fr .git && \ | |
cd ../ | |
echo '=================== Done ===================' | |
Push: | |
needs: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Push | |
uses: actions/checkout@v3 | |
with: | |
clean: true | |
repository: sysarmy/sysarmy.github.io | |
ref: master | |
ssh-key: ${{ secrets.SYSARMYDEPLOYKEY }} | |
- run: | | |
git config user.name github-actions | |
git config user.email github-actions@github.com | |
git submodule update --init --recursive | |
git submodule update --remote | |
git add . | |
git commit -m "Automated deployment to GitHub Pages for commit: ${{ github.sha }}" | |
git push |