mziesel.com/.gitea/workflows/hugo.yaml

85 lines
2.6 KiB
YAML
Raw Normal View History

2023-06-12 18:29:31 +00:00
on:
push:
2023-06-13 17:16:53 +00:00
branches:
2023-06-13 17:22:12 +00:00
- main
2023-06-13 17:16:53 +00:00
pull_request:
2023-10-01 21:48:20 +00:00
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types:
- webhook
2023-06-12 18:29:31 +00:00
jobs:
2023-06-13 17:16:53 +00:00
deploy:
2023-06-12 18:29:31 +00:00
runs-on: ubuntu-latest
2024-04-27 17:43:44 +00:00
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
RUNNER_TOOL_CACHE: /toolcache
2023-06-12 18:29:31 +00:00
steps:
2023-06-13 17:16:53 +00:00
- uses: actions/checkout@v3
2023-06-12 18:29:31 +00:00
with:
2023-06-13 17:16:53 +00:00
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
2023-06-12 20:15:41 +00:00
2023-06-13 17:16:53 +00:00
- name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2
2023-06-12 18:29:31 +00:00
with:
2024-04-27 17:28:07 +00:00
hugo-version: '0.124.0'
2023-06-13 17:16:53 +00:00
# extended: true
2023-06-12 18:29:31 +00:00
2023-06-13 17:22:12 +00:00
- name: Build site
2023-06-13 17:16:53 +00:00
run: hugo --minify
2023-09-30 18:02:41 +00:00
2024-04-27 17:28:07 +00:00
# -C switch means cd to public and then tar all contents
- name: Create tarfile
run: tar -cf website.tar -C public .
- name: Setup ssh
run: |
mkdir -p /home/runner/.ssh
ssh-keyscan ${{secrets.SSH_HOST}} >> /home/runner/.ssh/known_hosts
2024-04-27 17:35:42 +00:00
echo "${{ secrets.SSH_KEY }}" > /home/runner/.ssh/id_deployer
chmod 600 /home/runner/.ssh/id_deployer
2024-04-27 17:28:07 +00:00
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
2024-04-27 17:35:42 +00:00
ssh-add /home/runner/.ssh/id_deployer
2024-04-27 17:28:07 +00:00
- name: Deploy to server
2024-04-27 17:51:25 +00:00
uses: https://github.com/appleboy/scp-action@master
2024-04-27 17:55:44 +00:00
with:
2024-04-27 17:51:25 +00:00
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
source: ./website.tar
target: ${{SCP_DEST}}
overwrite: true
- name: Extract archive
2024-04-27 17:28:07 +00:00
run: |
2024-04-27 17:51:25 +00:00
#scp -i ~/.ssh/id_deployer ./website.tar ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}}:${{SCP_DEST}}
ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "rm -r ${{WEB_DIR}}/*"
ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "tar -xf ${{SCP_DEST}}/website.tar --directory ${{WEB_DIR}}/"
ssh ${{secrets.SSH_USER}}@${{secrets.SSH_HOST}} "rm ${{SCP_DEST}}/website.tar"
2024-04-27 17:28:07 +00:00
2023-09-30 18:13:49 +00:00
2023-09-30 18:35:50 +00:00
# - name: Create release
# id: create-release
# uses: actions/release-action@main
# with:
# files: |-
# website.tar
# api_key: '${{secrets.RELEASE_TOKEN}}'
2023-09-30 18:13:49 +00:00
2024-04-27 17:28:07 +00:00
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: website.tar
2023-07-08 18:18:37 +00:00
2024-04-27 17:28:07 +00:00
# - name: Setup Minio client
# run: wget https://dl.min.io/client/mc/release/linux-amd64/mc && chmod +x ./mc && ./mc alias set deploy ${{ secrets.S3_ENDPOINT }} ${{ secrets.S3_ACCESS_KEY }} ${{ secrets.S3_SECRET_KEY }}
#
# - name: Deploy to Garage
# run: ./mc mirror --remove --overwrite ./public/ deploy/${{ secrets.S3_BUCKET }}
2023-09-30 18:02:41 +00:00