57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
name: Publish Blog
|
|
|
|
on: push
|
|
|
|
jobs:
|
|
deploy:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
|
|
# CHEKCOUT REPOSITORY
|
|
|
|
- name: Git checkout
|
|
uses: actions/checkout@v3
|
|
|
|
# SETUP HUGO
|
|
|
|
# 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
|
|
|
|
- name: Setup Hugo
|
|
uses: peaceiris/actions-hugo@v2
|
|
with:
|
|
hugo-version: '${{ env.HUGO_VERSION }}'
|
|
extended: true
|
|
|
|
- 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
|
|
|
|
# DEPLOY TO REMOTE SERVER
|
|
|
|
- name: Install SSH Key
|
|
uses: shimataro/ssh-key-action@v2
|
|
with:
|
|
key: ${{ secrets.PRIVATE_SSH_KEY }}
|
|
known_hosts: 'placeholder'
|
|
|
|
- name: Adding Known Hosts
|
|
run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST_IP }} >> ~/.ssh/known_hosts
|
|
|
|
- name: Deploy with rsync
|
|
run: rsync -avz --delete ./public/ ${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST_IP }}:${{ secrets.DEPLOY_PATH }}
|