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 - name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2 uses: https://github.com/peaceiris/actions-hugo@v2
with: with:
hugo-version: '0.122.0' hugo-version: '0.124.0'
# extended: true # extended: true
- name: Build site - name: Build site
run: hugo --minify run: hugo --minify
# - name: Create tarfile # -C switch means cd to public and then tar all contents
# run: tar -cf website.tar public - 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 # - name: Create release
# id: create-release # id: create-release
@ -39,15 +62,15 @@ jobs:
# website.tar # website.tar
# api_key: '${{secrets.RELEASE_TOKEN}}' # api_key: '${{secrets.RELEASE_TOKEN}}'
# - name: Upload artifacts - name: Upload artifacts
# uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
# with: with:
# name: website-files.tar name: website-files.tar
# path: website.tar path: website.tar
- name: Setup Minio client # - 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 }} # 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 # - name: Deploy to Garage
run: ./mc mirror --remove --overwrite ./public/ deploy/${{ secrets.S3_BUCKET }} # 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}}'