2024-06-11 10:51:28 +00:00
|
|
|
run-name: ${{ gitea.actor }}, deploy with ssh
|
2024-06-13 13:59:12 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- "release"
|
2024-06-09 11:42:32 +00:00
|
|
|
|
|
|
|
env:
|
2024-06-11 10:51:28 +00:00
|
|
|
BUILD_PATH: "."
|
2024-06-09 11:42:32 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-06-11 10:51:28 +00:00
|
|
|
build:
|
|
|
|
name: Build
|
2024-06-09 11:42:32 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-06-11 10:51:28 +00:00
|
|
|
- name: Checkout
|
2024-06-09 11:42:32 +00:00
|
|
|
uses: actions/checkout@v4
|
2024-06-11 10:51:28 +00:00
|
|
|
- name: Detect package manager
|
|
|
|
id: detect-package-manager
|
|
|
|
run: |
|
|
|
|
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
|
|
|
|
echo "manager=yarn" >> $GITHUB_OUTPUT
|
|
|
|
echo "command=install" >> $GITHUB_OUTPUT
|
|
|
|
echo "runner=yarn" >> $GITHUB_OUTPUT
|
|
|
|
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
|
|
|
|
exit 0
|
|
|
|
elif [ -f "${{ github.workspace }}/package.json" ]; then
|
|
|
|
echo "manager=npm" >> $GITHUB_OUTPUT
|
|
|
|
echo "command=ci" >> $GITHUB_OUTPUT
|
|
|
|
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
|
|
|
|
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Unable to determine package manager"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
- name: Setup Node
|
|
|
|
uses: actions/setup-node@v4
|
2024-06-09 11:48:33 +00:00
|
|
|
with:
|
2024-06-11 10:51:28 +00:00
|
|
|
node-version: "20"
|
|
|
|
cache: ${{ steps.detect-package-manager.outputs.manager }}
|
|
|
|
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
|
|
|
|
- name: Install dependencies
|
|
|
|
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
|
|
|
|
working-directory: ${{ env.BUILD_PATH }}
|
2024-06-11 11:43:13 +00:00
|
|
|
- name: Make envfile
|
|
|
|
uses: SpicyPizza/create-envfile@v2.0
|
|
|
|
with:
|
|
|
|
envkey_PUBLIC_BACKEND_HOST: ${{ vars.PUBLIC_BACKEND_HOST }}
|
2024-06-11 10:51:28 +00:00
|
|
|
- name: Build with Astro
|
|
|
|
run: |
|
|
|
|
${{ steps.detect-package-manager.outputs.runner }} astro build
|
|
|
|
working-directory: ${{ env.BUILD_PATH }}
|
|
|
|
- name: Deploy to my server
|
2024-06-13 19:56:36 +00:00
|
|
|
id: deploy
|
2024-06-11 10:51:28 +00:00
|
|
|
uses: up9cloud/action-rsync@master
|
|
|
|
env:
|
2024-06-11 11:18:42 +00:00
|
|
|
USER: ${{ secrets.USERNAME }}
|
2024-06-11 10:51:28 +00:00
|
|
|
HOST: ${{ secrets.HOST }}
|
|
|
|
KEY: ${{ secrets.KEY }}
|
2024-06-11 11:18:42 +00:00
|
|
|
SOURCE: ./dist/
|
2024-06-11 10:51:28 +00:00
|
|
|
TARGET: ${{ secrets.DESTINATION_FOLDER }}
|
|
|
|
|
2024-06-11 11:18:42 +00:00
|
|
|
ARGS: -avz --exclude=/.git/
|
2024-06-11 10:51:28 +00:00
|
|
|
SSH_ARGS: "-p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
2024-06-11 11:18:42 +00:00
|
|
|
VERBOSE: true
|
2024-06-11 10:51:28 +00:00
|
|
|
|
|
|
|
PRE_SCRIPT: |
|
|
|
|
echo start at:
|
|
|
|
date -u
|
|
|
|
POST_SCRIPT: "echo done at: && date -u"
|
2024-06-13 19:56:36 +00:00
|
|
|
- name: Send email notification
|
|
|
|
uses: dawidd6/action-send-mail@v3
|
|
|
|
if: ${{ always() }}
|
2024-06-09 11:42:32 +00:00
|
|
|
with:
|
2024-06-13 19:56:36 +00:00
|
|
|
server_address: mail.log101.dev
|
|
|
|
server_port: 465
|
|
|
|
secure: true
|
|
|
|
username: ${{secrets.MAIL_USERNAME}}
|
|
|
|
password: ${{secrets.MAIL_PASSWORD}}
|
|
|
|
subject: Github Actions job result
|
|
|
|
to: ffrknerdm@gmail.com
|
|
|
|
from: gitea@log101.dev
|
|
|
|
body: Build job of ${{github.repository}} completed with status ${{ steps.deploy.outcome }}!
|