add GitHub Actions workflow for build and deployment
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 1m46s
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 1m46s
This commit is contained in:
44
.gitea/workflows/deploy.yml
Normal file
44
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,44 @@
|
||||
name: Build and Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2
|
||||
with:
|
||||
hugo-version: 'latest'
|
||||
extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --minify
|
||||
|
||||
- name: Install SSH Key
|
||||
uses: shimataro/ssh-key-action@v2
|
||||
with:
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
known_hosts: unnecessary
|
||||
if_key_exists: replace
|
||||
|
||||
- name: Adding Known Hosts
|
||||
run: ssh-keyscan -p ${{ secrets.SERVER_PORT }} -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy with rsync
|
||||
run: |
|
||||
rsync -avz --delete -e "ssh -p ${{ secrets.SERVER_PORT }}" \
|
||||
./public/ ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:${{ secrets.DEPLOY_PATH }}
|
||||
|
||||
- name: Restart Docker container
|
||||
run: |
|
||||
ssh -p ${{ secrets.SERVER_PORT }} ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} \
|
||||
"cd ${{ secrets.DEPLOY_PATH }} && sudo docker compose -f docker-compose.prod.yml up -d --build"
|
||||
Reference in New Issue
Block a user