ci: add CD pipeline with Docker Hub push on pre-prod
This commit is contained in:
@@ -2,13 +2,13 @@ name: Backend - Build & Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [pre-prod]
|
||||
paths:
|
||||
- "backend/**/**"
|
||||
- "backend/**"
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [pre-prod]
|
||||
paths:
|
||||
- "backend/**/**"
|
||||
- "backend/**"
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
@@ -54,9 +54,40 @@ jobs:
|
||||
working-directory: backend/gestion
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Upload binary
|
||||
uses: actions/upload-artifact@v4
|
||||
docker:
|
||||
name: Docker Build & Push
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
name: backend-binary
|
||||
path: backend/gestion/gestion
|
||||
retention-days: 7
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build & push backend (runtime)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/backend/Dockerfile
|
||||
target: runtime
|
||||
push: true
|
||||
tags: |
|
||||
xor1234/backend-mln:latest
|
||||
|
||||
- name: Build & push WAF
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: docker/backend/Dockerfile
|
||||
target: waf
|
||||
push: true
|
||||
tags: |
|
||||
xor1234/backend-mln:waf
|
||||
|
||||
Reference in New Issue
Block a user