fix: deploy.yml
This commit is contained in:
parent
8328588aa8
commit
af784c5b63
1 changed files with 45 additions and 53 deletions
98
.github/workflows/deploy.yml
vendored
98
.github/workflows/deploy.yml
vendored
|
@ -1,57 +1,49 @@
|
||||||
name: Publish Blog
|
|
||||||
|
|
||||||
on: push
|
name: build and deploy site
|
||||||
|
|
||||||
|
# The trigger for the action
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
# Jobs are contains steps
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
build_deploy:
|
||||||
|
name: build and deploy
|
||||||
runs-on: ubuntu-22.04
|
# This job runs on linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
# The first step is provided by GitHub and it checks out
|
||||||
# CHEKCOUT REPOSITORY
|
# the master branch on the runner
|
||||||
|
- uses: actions/checkout@master
|
||||||
- name: Git checkout
|
with:
|
||||||
uses: actions/checkout@v3
|
submodules: true
|
||||||
|
|
||||||
# SETUP HUGO
|
# This step uses an action created by a user which sets
|
||||||
|
# up Hugo on the runner and runs the hugo command to build
|
||||||
# Read environemnt variable for subsequent actions.
|
# the site
|
||||||
# See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
- name: Setup Hugo
|
||||||
- name: Read .env
|
uses: peaceiris/actions-hugo@v2
|
||||||
run: |
|
with:
|
||||||
. ./.env
|
hugo-version: '0.122.0'
|
||||||
echo "HUGO_VERSION=${HUGO_VERSION}" >> $GITHUB_ENV
|
|
||||||
|
- name: Build
|
||||||
- name: Setup Hugo
|
run: hugo --minify
|
||||||
uses: peaceiris/actions-hugo@v2
|
|
||||||
with:
|
# The last step deploys the site to my server by running
|
||||||
hugo-version: '${{ env.HUGO_VERSION }}'
|
# the deploy script located in the ci directory
|
||||||
extended: true
|
# within the repo
|
||||||
|
- name: deploy
|
||||||
- name: Cache Hugo
|
run: source $GITHUB_WORKSPACE/ci/deploy.sh
|
||||||
uses: actions/cache@v3
|
env:
|
||||||
with:
|
# This section sets up the environment used by the
|
||||||
path: /tmp/hugo_cache
|
# deploy script. These values are injected from
|
||||||
key: ${{ runner.os }}-hugomod-${{ hashFiles('**/go.sum') }}
|
# the repo's secret store
|
||||||
restore-keys: |
|
ACTIONS_DEPLOY_KEY: ${{ secrets.BDEPLOY_KEY }}
|
||||||
${{ runner.os }}-hugomod-
|
SSH_USERNAME: ${{ secrets.SSH_USER }}
|
||||||
|
SERVER_ADDRESS: ${{ secrets.SSH_SERVER }}
|
||||||
- name: Build Blog
|
SERVER_DESTINATION: ${{ secrets.DEST_DIR }}
|
||||||
env:
|
SSH_PORT: ${{ secrets.SSH_PORT }}
|
||||||
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 }}
|
|
||||||
|
|
Loading…
Reference in a new issue