ci(gitea): séparation des déploiements test et prod selon les branches
This commit is contained in:
+36
-3
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 'prod/*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
@@ -26,10 +27,11 @@ jobs:
|
||||
- name: Run Maven Tests
|
||||
run: mvn clean test
|
||||
|
||||
deploy:
|
||||
name: Build & Run in Docker Container
|
||||
deploy_test:
|
||||
name: Deploy to Test Environment
|
||||
needs: test
|
||||
runs-on: self-hosted
|
||||
if: github.ref == 'refs/heads/main'
|
||||
runs-on: [self-hosted, test]
|
||||
container:
|
||||
image: docker:latest
|
||||
steps:
|
||||
@@ -51,3 +53,34 @@ jobs:
|
||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||
docker compose down app || true
|
||||
docker compose up -d --build app
|
||||
|
||||
deploy_prod:
|
||||
name: Deploy to Prod Environment
|
||||
needs: test
|
||||
if: startsWith(github.ref, 'refs/heads/prod/')
|
||||
runs-on: [self-hosted, prod]
|
||||
container:
|
||||
image: docker:latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
SERVER_URL="${{ github.server_url }}"
|
||||
SERVER_NO_PROTO="${SERVER_URL#http://}"
|
||||
SERVER_NO_PROTO="${SERVER_NO_PROTO#https://}"
|
||||
git clone --depth 1 "https://oauth2:${{ secrets.GITHUB_TOKEN }}@${SERVER_NO_PROTO}/${{ github.repository }}.git" .
|
||||
git checkout ${{ github.sha }}
|
||||
|
||||
- name: Deploy with Docker Compose
|
||||
env:
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
CAPTCHA_SECRET: ${{ secrets.CAPTCHA_SECRET }}
|
||||
CAPTCHA_SITEKEY: ${{ secrets.CAPTCHA_SITEKEY }}
|
||||
run: |
|
||||
echo "POSTGRES_USER=${DB_USER:-myuser}" > .env
|
||||
echo "POSTGRES_PASSWORD=${DB_PASSWORD:-mypassword}" >> .env
|
||||
echo "CAPTCHA_SECRET=${CAPTCHA_SECRET:-1x0000000000000000000000000000000AA}" >> .env
|
||||
echo "CAPTCHA_SITEKEY=${CAPTCHA_SITEKEY:-1x00000000000000000000AA}" >> .env
|
||||
docker compose down app || true
|
||||
docker compose up -d --build app
|
||||
|
||||
Reference in New Issue
Block a user