Skip to Content

CI/CD

Dockerfile
Tout dépend de votre projet 😉 Mais à faire tourner sous le port 80 hostname 0.0.0.0
.env
NAME="nom-projet-branch" # le nom de votre projet github doit être en minuscule
docker-compose.yml
services: app: build: . env_file: .env image: ${NAME}_image networks: ["network", "nginx-proxy_network"] container_name: ${NAME} restart: always networks: network: driver: bridge nginx-proxy_network: external: true
.github/workflows/ci.yml
name: CI on: push: branches: ["develop", "preview", "release"] workflow_dispatch: permissions: id-token: 'write' contents: 'read' env: project: ${{ github.event.repository.name }} branch: ${{ github.ref_name }} jobs: build: runs-on: self-hosted steps: - name: Checkout repository uses: actions/checkout@v4 - name: Create .env file based on the branch run: echo "${{ secrets[env.branch] }}" >> .env - name: Build and run the Docker container run: docker compose -p $project-$branch up --build -d cleanup: runs-on: self-hosted needs: build steps: - name: Cleanup images run: docker image prune -f - name: Cleaning directory run: cd "$(dirname "$RUNNER_WORKSPACE")" && rm -rf $project _PipelineMapping _temp