again... fixing deployment actions
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# .gitea/workflows/deploy.yml
|
||||
# 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):
|
||||
# DEPLOY_HOST — droplet IP or hostname
|
||||
@@ -23,7 +23,9 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
- name: Verify Node.js
|
||||
run: node --version && npm --version
|
||||
@@ -55,24 +57,20 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: ${{ secrets.DEPLOY_USER }}
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
port: ${{ secrets.DEPLOY_PORT }}
|
||||
script: |
|
||||
set -e
|
||||
APP_DIR=/opt/etc-prs/app
|
||||
APP_USER=prs
|
||||
echo "▸ Pulling latest code…"
|
||||
cd "$APP_DIR" && git pull
|
||||
echo "▸ Installing dependencies…"
|
||||
npm install --quiet
|
||||
echo "▸ Building…"
|
||||
npm run build
|
||||
echo "▸ Fixing ownership…"
|
||||
chown -R "${APP_USER}:${APP_USER}" "$APP_DIR"
|
||||
echo "▸ Reloading PM2…"
|
||||
pm2 reload etc-prs
|
||||
echo "✓ Deploy complete"
|
||||
run: |
|
||||
# Write the private key to a temp file
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
|
||||
chmod 600 ~/.ssh/deploy_key
|
||||
|
||||
# Disable strict host checking so first connection doesn't hang
|
||||
echo "StrictHostKeyChecking no" >> ~/.ssh/config
|
||||
|
||||
# SSH in and run the redeploy script
|
||||
ssh -i ~/.ssh/deploy_key \
|
||||
-p ${{ secrets.DEPLOY_PORT }} \
|
||||
${{ secrets.DEPLOY_USER }}@${{ secrets.DEPLOY_HOST }} \
|
||||
"bash /opt/etc-prs/app/scripts/redeploy.sh"
|
||||
|
||||
# Clean up
|
||||
rm -f ~/.ssh/deploy_key
|
||||
|
||||
Reference in New Issue
Block a user