deploy scripts
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
name: Build & Deploy
|
||||
|
||||
on:
|
||||
push
|
||||
|
||||
env:
|
||||
REGISTRY: git.aggtaa.com
|
||||
IMAGE_PREFIX: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
# ── BUILD SERVER ──────────────────────────────────────────────────────────────
|
||||
build-app:
|
||||
runs-on: docker1
|
||||
defaults:
|
||||
run:
|
||||
shell: sh
|
||||
working-directory: /workspace
|
||||
steps:
|
||||
- name: Checkout
|
||||
working-directory: /
|
||||
run: |
|
||||
mkdir -p /workspace
|
||||
if [ -d /workspace/.git ]; then
|
||||
cd /workspace && git fetch origin && git reset --hard origin/${{ gitea.ref_name }}
|
||||
else
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /workspace
|
||||
fi
|
||||
|
||||
- name: Build & push app
|
||||
run: |
|
||||
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
|
||||
docker login ${{ env.REGISTRY }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
|
||||
|
||||
/data/tools/docker-buildx build \
|
||||
--cache-from type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:cache \
|
||||
--cache-to type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:cache,mode=max \
|
||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:latest \
|
||||
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:${{ gitea.sha }} \
|
||||
--file Dockerfile \
|
||||
--push \
|
||||
.
|
||||
|
||||
# ── DEPLOY ────────────────────────────────────────────────────────────────────
|
||||
deploy:
|
||||
runs-on: docker1
|
||||
needs: [build-app]
|
||||
if: always() && !failure() && !cancelled()
|
||||
defaults:
|
||||
run:
|
||||
shell: sh
|
||||
steps:
|
||||
- name: Deploy
|
||||
run: |
|
||||
mkdir -p "/app-cache/${{ gitea.repository }}"
|
||||
cd "/app-cache/${{ gitea.repository }}"
|
||||
if [ ! -d .git ]; then
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||
else
|
||||
git pull origin main
|
||||
fi
|
||||
printf 'REGISTRY=%s\nIMAGE_PREFIX=%s\n' \
|
||||
'${{ env.REGISTRY }}' \
|
||||
'${{ env.IMAGE_PREFIX }}' > .env
|
||||
docker compose pull
|
||||
docker compose up -d --remove-orphans
|
||||
docker image prune -f
|
||||
Reference in New Issue
Block a user