Add GitHub Actions deployment workflow #45
49
.gitea/workflows/deploy.yml
Normal file
49
.gitea/workflows/deploy.yml
Normal file
@ -0,0 +1,49 @@
|
||||
name: Hugo Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test_build:
|
||||
name: Build Hugo Site
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: klakegg/hugo:0.111.3-ext-alpine-ci
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Check Hugo Version and Build
|
||||
run: |
|
||||
hugo version
|
||||
hugo --minify
|
||||
|
||||
deploy:
|
||||
name: Deploy to Server
|
||||
runs-on: ubuntu-latest
|
||||
needs: test_build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup SSH and Deploy
|
||||
run: |
|
||||
eval "$(ssh-agent -s)"
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
|
||||
chmod 700 ~/.ssh
|
||||
ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts
|
||||
chmod 644 ~/.ssh/known_hosts
|
||||
|
||||
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" 'cd repo && git stash && git pull --force origin master && ./build.sh'
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
SSH_PORT: ${{ secrets.SSH_PORT }}
|
Loading…
x
Reference in New Issue
Block a user