again... fixing deployment actions
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# .gitea/workflows/ci.yml
|
# .gitea/workflows/ci.yml
|
||||||
# Runs on every push and pull request (except main, which uses deploy.yml).
|
# Runs on every push and pull request (except main, which uses deploy.yml).
|
||||||
# Designed for a host-mode act_runner on Ubuntu with Node 20 already installed.
|
# Uses no external actions — all steps are plain shell commands.
|
||||||
|
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
@@ -17,7 +17,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
run: |
|
||||||
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||||
|
git checkout ${{ gitea.sha }}
|
||||||
|
|
||||||
- name: Verify Node.js
|
- name: Verify Node.js
|
||||||
run: node --version && npm --version
|
run: node --version && npm --version
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# .gitea/workflows/deploy.yml
|
# .gitea/workflows/deploy.yml
|
||||||
# Triggered on push to main.
|
# Triggered on push to main.
|
||||||
# Runs CI checks first, then deploys to production.
|
# Uses no external actions — all steps are plain shell commands.
|
||||||
#
|
#
|
||||||
# Required Gitea secrets (Settings → Secrets → Actions):
|
# Required Gitea secrets (Settings → Secrets → Actions):
|
||||||
# DEPLOY_HOST — droplet IP or hostname
|
# DEPLOY_HOST — droplet IP or hostname
|
||||||
@@ -23,7 +23,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
run: |
|
||||||
|
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||||
|
git checkout ${{ gitea.sha }}
|
||||||
|
|
||||||
- name: Verify Node.js
|
- name: Verify Node.js
|
||||||
run: node --version && npm --version
|
run: node --version && npm --version
|
||||||
@@ -55,24 +57,20 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploy via SSH
|
- name: Deploy via SSH
|
||||||
uses: appleboy/ssh-action@v1.0.3
|
run: |
|
||||||
with:
|
# Write the private key to a temp file
|
||||||
host: ${{ secrets.DEPLOY_HOST }}
|
mkdir -p ~/.ssh
|
||||||
username: ${{ secrets.DEPLOY_USER }}
|
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
chmod 600 ~/.ssh/deploy_key
|
||||||
port: ${{ secrets.DEPLOY_PORT }}
|
|
||||||
script: |
|
# Disable strict host checking so first connection doesn't hang
|
||||||
set -e
|
echo "StrictHostKeyChecking no" >> ~/.ssh/config
|
||||||
APP_DIR=/opt/etc-prs/app
|
|
||||||
APP_USER=prs
|
# SSH in and run the redeploy script
|
||||||
echo "▸ Pulling latest code…"
|
ssh -i ~/.ssh/deploy_key \
|
||||||
cd "$APP_DIR" && git pull
|
-p ${{ secrets.DEPLOY_PORT }} \
|
||||||
echo "▸ Installing dependencies…"
|
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} \
|
||||||
npm install --quiet
|
"bash /opt/etc-prs/app/scripts/redeploy.sh"
|
||||||
echo "▸ Building…"
|
|
||||||
npm run build
|
# Clean up
|
||||||
echo "▸ Fixing ownership…"
|
rm -f ~/.ssh/deploy_key
|
||||||
chown -R "${APP_USER}:${APP_USER}" "$APP_DIR"
|
|
||||||
echo "▸ Reloading PM2…"
|
|
||||||
pm2 reload etc-prs
|
|
||||||
echo "✓ Deploy complete"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user