change ci/cd setup
All checks were successful
/ deploy (push) Successful in 54s

This commit is contained in:
Mans Ziesel 2024-04-27 19:28:07 +02:00
parent aa53794b91
commit 84c5b1a04b
2 changed files with 36 additions and 53 deletions

View File

@ -22,14 +22,37 @@ jobs:
- name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2
with:
hugo-version: '0.122.0'
hugo-version: '0.124.0'
# extended: true
- name: Build site
run: hugo --minify
# - name: Create tarfile
# run: tar -cf website.tar public
# -C switch means cd to public and then tar all contents
- name: Create tarfile
run: tar -cf website.tar -C public .
- name: Setup ssh
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p /home/runner/.ssh
ssh-keyscan ${{secrets.SSH_HOST}} >> /home/runner/.ssh/known_hosts
echo "${{ secrets.SSH_KEY }}" > /home/runner/.ssh/id_rsa
chmod 600 /home/runner/.ssh/id_rsa
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add /home/runner/.ssh/id_rsa
- name: Deploy to server
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
scp ./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'
# - name: Create release
# id: create-release
@ -39,15 +62,15 @@ jobs:
# website.tar
# api_key: '${{secrets.RELEASE_TOKEN}}'
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# name: website-files.tar
# path: website.tar
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: website-files.tar
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 }}
# - 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 }}

View File

@ -1,40 +0,0 @@
name: release
on:
push:
tags:
- '*'
jobs:
release:
runs-on: ubuntu-latest
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 go
uses: https://github.com/actions/setup-go@v4
with:
go-version: '>=1.20.1'
- name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2
with:
hugo-version: '0.111.3'
# extended: true
- name: Build site
run: hugo --minify
- name: Create tarfile
run: tar -cf website.tar public
- name: Create relesase
id: create-release-action
uses: https://gitea.com/actions/release-action@main
with:
files: |-
website.tar
api_key: '${{secrets.RELEASE_TOKEN}}'