Update .gitea/workflows/deploy.yml
Some checks failed
Deploy PHP App / deploy (push) Failing after 10s
Some checks failed
Deploy PHP App / deploy (push) Failing after 10s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
name: Deploy PHP App
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
@@ -9,9 +10,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy to server
|
||||
env:
|
||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||
@@ -19,8 +17,8 @@ jobs:
|
||||
SSH_USER: ${{ secrets.SSH_USER }}
|
||||
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||
APP_DIR: ${{ secrets.APP_DIR }}
|
||||
REPO_URL: ${{ gitea.server_url }}/${{ gitea.repository }}.git
|
||||
BRANCH: ${{ gitea.ref_name }}
|
||||
REPO_URL: https://gitea.myaccess.cloud/${{ gitea.repository }}.git
|
||||
BRANCH: main
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
||||
@@ -30,29 +28,18 @@ jobs:
|
||||
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "
|
||||
set -e
|
||||
|
||||
echo '--- Preparing app directory ---'
|
||||
mkdir -p \"$APP_DIR\"
|
||||
|
||||
if [ -d \"$APP_DIR/.git\" ]; then
|
||||
echo 'Repo exists. Pulling latest code...'
|
||||
echo 'Repo exists, pulling latest code'
|
||||
cd \"$APP_DIR\"
|
||||
git fetch origin
|
||||
git reset --hard origin/$BRANCH
|
||||
else
|
||||
echo 'Repo does not exist. Cloning fresh copy...'
|
||||
echo 'Repo does not exist, cloning fresh'
|
||||
rm -rf \"$APP_DIR\"
|
||||
git clone -b \"$BRANCH\" \"$REPO_URL\" \"$APP_DIR\"
|
||||
cd \"$APP_DIR\"
|
||||
fi
|
||||
|
||||
echo '--- Stopping old containers ---'
|
||||
docker compose down --remove-orphans || true
|
||||
|
||||
echo '--- Removing old unused images ---'
|
||||
docker image prune -af || true
|
||||
|
||||
echo '--- Starting new containers ---'
|
||||
docker compose up -d --build
|
||||
|
||||
echo '--- Deployment completed ---'
|
||||
"
|
||||
Reference in New Issue
Block a user