2024-02-17 11:20:10 +00:00
|
|
|
name: Publish Blog
|
2021-10-16 08:31:21 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
on: push
|
2021-10-16 08:31:21 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-02-17 11:20:10 +00:00
|
|
|
deploy:
|
2024-02-16 21:48:55 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
runs-on: ubuntu-22.04
|
2024-02-16 21:48:55 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
# CHEKCOUT REPOSITORY
|
2024-02-16 21:48:55 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
- name: Git checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
# SETUP HUGO
|
2024-02-16 21:48:55 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
# Read environemnt variable for subsequent actions.
|
|
|
|
# See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
|
|
|
- name: Read .env
|
|
|
|
run: |
|
|
|
|
. ./.env
|
|
|
|
echo "HUGO_VERSION=${HUGO_VERSION}" >> $GITHUB_ENV
|
2024-02-16 21:48:55 +00:00
|
|
|
|
|
|
|
- name: Setup Hugo
|
|
|
|
uses: peaceiris/actions-hugo@v2
|
|
|
|
with:
|
2024-02-17 11:20:10 +00:00
|
|
|
hugo-version: '${{ env.HUGO_VERSION }}'
|
2024-02-16 21:48:55 +00:00
|
|
|
extended: true
|
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
- name: Cache Hugo
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: /tmp/hugo_cache
|
|
|
|
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-hugomod-
|
|
|
|
|
|
|
|
- name: Build Blog
|
|
|
|
env:
|
|
|
|
TZ: 'Europe/Rome'
|
|
|
|
run: hugo --minify
|
2024-02-16 21:48:55 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
# DEPLOY TO REMOTE SERVER
|
|
|
|
|
|
|
|
- name: Install SSH Key
|
|
|
|
uses: shimataro/ssh-key-action@v2
|
2024-02-16 21:48:55 +00:00
|
|
|
with:
|
2024-02-17 11:20:10 +00:00
|
|
|
key: ${{ secrets.PRIVATE_SSH_KEY }}
|
|
|
|
known_hosts: 'placeholder'
|
|
|
|
|
|
|
|
- name: Adding Known Hosts
|
|
|
|
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST_IP }} >> ~/.ssh/known_hosts
|
2024-02-16 21:48:55 +00:00
|
|
|
|
2024-02-17 11:20:10 +00:00
|
|
|
- name: Deploy with rsync
|
|
|
|
run: rsync -avz --delete ./public/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST_IP }}:${{ secrets.DEPLOY_PATH }}
|