konulu-konum/.gitea/workflows/static-deploy.yml

80 lines
2.5 KiB
YAML
Raw Normal View History

2024-07-29 16:06:56 +00:00
run-name: ${{ gitea.actor }}, deploy with ssh
on:
push:
branches:
- "release"
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
2024-07-29 16:18:24 +00:00
- name: Install package manager (from package.json)
run: |
corepack enable
corepack install
2024-07-29 16:06:56 +00:00
- 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: Make envfile
uses: SpicyPizza/create-envfile@v2.0
with:
envkey_PUBLIC_BACKEND_HOST: ${{ vars.PUBLIC_BACKEND_URL }}
2024-07-29 16:06:56 +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
id: deploy
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"