75 lines
2.8 KiB
YAML
75 lines
2.8 KiB
YAML
run-name: ${{ gitea.actor }}, deploy with ssh
|
|
on: [push]
|
|
|
|
env:
|
|
BUILD_PATH: "."
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- 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
|
|
with:
|
|
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 }}
|
|
- name: Build with Astro
|
|
run: |
|
|
${{ steps.detect-package-manager.outputs.runner }} astro build
|
|
working-directory: ${{ env.BUILD_PATH }}
|
|
- uses: webfactory/ssh-agent@v0.9.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.KEY }}
|
|
- name: Deploy to my server
|
|
uses: up9cloud/action-rsync@master
|
|
env:
|
|
USER: ${{ secrets.USERNAME }}
|
|
HOST: ${{ secrets.HOST }}
|
|
KEY: ${{ secrets.KEY }}
|
|
SOURCE: ./dist/
|
|
TARGET: ${{ secrets.DESTINATION_FOLDER }}
|
|
|
|
ARGS: -avz --exclude=/.git/
|
|
SSH_ARGS: "-p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
|
|
VERBOSE: true
|
|
|
|
PRE_SCRIPT: |
|
|
echo start at:
|
|
date -u
|
|
POST_SCRIPT: "echo done at: && date -u"
|
|
- name: Send mail
|
|
uses: appleboy/ssh-action@v1.0.3
|
|
with:
|
|
host: ${{ secrets.HOST }}
|
|
username: ${{ secrets.USERNAME }}
|
|
key: ${{ secrets.KEY }}
|
|
port: ${{ secrets.PORT }}
|
|
script: |
|
|
echo -e "Subject: Act Runner Report: ${{ job.status}}\nFrom: gitea@log101.dev\n\nJob has finished with status ${{ job.status }}\n${{ github.repository }}: [${{ github.ref }}@${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/actions)" | sendmail ffrknerdm@gmail.com
|