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
|
name: Deploy PHP App
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -9,9 +10,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Deploy to server
|
- name: Deploy to server
|
||||||
env:
|
env:
|
||||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||||
@@ -19,8 +17,8 @@ jobs:
|
|||||||
SSH_USER: ${{ secrets.SSH_USER }}
|
SSH_USER: ${{ secrets.SSH_USER }}
|
||||||
SSH_KEY: ${{ secrets.SSH_KEY }}
|
SSH_KEY: ${{ secrets.SSH_KEY }}
|
||||||
APP_DIR: ${{ secrets.APP_DIR }}
|
APP_DIR: ${{ secrets.APP_DIR }}
|
||||||
REPO_URL: ${{ gitea.server_url }}/${{ gitea.repository }}.git
|
REPO_URL: https://gitea.myaccess.cloud/${{ gitea.repository }}.git
|
||||||
BRANCH: ${{ gitea.ref_name }}
|
BRANCH: main
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
echo "$SSH_KEY" > ~/.ssh/id_rsa
|
||||||
@@ -30,29 +28,18 @@ jobs:
|
|||||||
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "
|
ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" "
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo '--- Preparing app directory ---'
|
|
||||||
mkdir -p \"$APP_DIR\"
|
|
||||||
|
|
||||||
if [ -d \"$APP_DIR/.git\" ]; then
|
if [ -d \"$APP_DIR/.git\" ]; then
|
||||||
echo 'Repo exists. Pulling latest code...'
|
echo 'Repo exists, pulling latest code'
|
||||||
cd \"$APP_DIR\"
|
cd \"$APP_DIR\"
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git reset --hard origin/$BRANCH
|
git reset --hard origin/$BRANCH
|
||||||
else
|
else
|
||||||
echo 'Repo does not exist. Cloning fresh copy...'
|
echo 'Repo does not exist, cloning fresh'
|
||||||
rm -rf \"$APP_DIR\"
|
rm -rf \"$APP_DIR\"
|
||||||
git clone -b \"$BRANCH\" \"$REPO_URL\" \"$APP_DIR\"
|
git clone -b \"$BRANCH\" \"$REPO_URL\" \"$APP_DIR\"
|
||||||
cd \"$APP_DIR\"
|
cd \"$APP_DIR\"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '--- Stopping old containers ---'
|
|
||||||
docker compose down --remove-orphans || true
|
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
|
docker compose up -d --build
|
||||||
|
|
||||||
echo '--- Deployment completed ---'
|
|
||||||
"
|
"
|
||||||
Reference in New Issue
Block a user