add autodeploy and add basic auth for file uploader
Some checks failed
Deploy back2 / deploy (push) Failing after 46s
Some checks failed
Deploy back2 / deploy (push) Failing after 46s
This commit is contained in:
68
.gitea/workflows/deploy.yml
Normal file
68
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Deploy back2
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
|
||||
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
|
||||
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
|
||||
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup SSH key
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_ed25519
|
||||
chmod 600 ~/.ssh/id_ed25519
|
||||
ssh-keyscan -p "${DEPLOY_PORT:-22}" -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy Laravel
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
ssh -p "${DEPLOY_PORT:-22}" "$DEPLOY_USER@$DEPLOY_HOST" "DEPLOY_PATH='$DEPLOY_PATH' bash -s" <<'EOF'
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "${DEPLOY_PATH:-}" ]; then
|
||||
echo "DEPLOY_PATH is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$DEPLOY_PATH"
|
||||
|
||||
if [ ! -d .git ]; then
|
||||
echo "Expected a git repository at $DEPLOY_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git fetch origin main
|
||||
git checkout main
|
||||
git reset --hard origin/main
|
||||
|
||||
if [ -f composer.json ]; then
|
||||
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
|
||||
fi
|
||||
|
||||
if [ -f artisan ]; then
|
||||
php artisan down --retry=60 || true
|
||||
trap 'php artisan up || true' EXIT
|
||||
|
||||
php artisan optimize:clear
|
||||
php artisan migrate --force
|
||||
php artisan storage:link || true
|
||||
php artisan config:cache
|
||||
php artisan view:cache
|
||||
php artisan queue:restart || true
|
||||
fi
|
||||
EOF
|
||||
Reference in New Issue
Block a user