mziesel.com/.gitea/workflows/hugo.yaml
Mans Ziesel 71d75703d8
All checks were successful
/ deploy (push) Successful in 44s
test
2024-04-27 20:22:53 +02:00

99 lines
2.9 KiB
YAML

on:
push:
branches:
- main
pull_request:
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types:
- webhook
jobs:
deploy:
runs-on: ubuntu-latest
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
RUNNER_TOOL_CACHE: /toolcache
steps:
- uses: actions/checkout@v3
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2
with:
hugo-version: '0.124.0'
# extended: true
- name: Build site
run: hugo --minify
# -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
# echo "${{ secrets.SSH_KEY }}" > /home/runner/.ssh/id_deployer
# chmod 600 /home/runner/.ssh/id_deployer
# ssh-agent -a $SSH_AUTH_SOCK > /dev/null
# ssh-add /home/runner/.ssh/id_deployer
- name: Deploy to server
uses: https://github.com/appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
source: ./website.tar
target: /tmp/
overwrite: true
- name: Test
run: echo "rm -r ${{ WEB_DIR }}"
- name: Test
run: echo "rm -r ${{ SSH_USER }}"
- name: Test
run: echo "rm -r ${{ SSH_USER }}/*"
- name: Test
run: echo "rm -r ${{ WEB_DIR }}/*"
- name: Test
run: 'echo "test"'
- name: Test
run: echo "test"
- name: Extract archive (test)
uses: https://github.com/appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
#script: rm -r ${{ WEB_DIR }}/* && tar -xvf /tmp/website.tar --directory ${{ WEB_DIR }}/ && rm /tmp/website.tar
script: "rm -r ${{ WEB_DIR }}/*"
# - name: Create release
# id: create-release
# uses: actions/release-action@main
# with:
# files: |-
# website.tar
# api_key: '${{secrets.RELEASE_TOKEN}}'
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: website.tar
# - 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 }}