name: Build release Docker image on: [push] env: DOCKER_IMAGE_NAME: harmony-back DOCKER_REGISTRY_URL: git.harmonylab.ovh DOCKER_REGISTRY_ORG: harmony RELEASE_VERSION: 1.2.0 DOCKPLOY_WEBHOOK_URL: http://192.168.0.220:3000/api/deploy/DxPrQ9JtATe40vH4N35KB DISCORD_WEBHOOK_URL: https://discord.com/api/webhooks/1433240422901088339/GAvL79ESBRabkB6rvxN2DsWI74KJ_Szgp9W2_PycPIY113rMCT_9LvIv-iTLCMD9W9qH jobs: build_docker_images: # Job name that shows in the GitHub UI name: Build Docker Images # Runner to use runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: get-npm-version id: package-version uses: martinbeentjes/npm-get-version-action@v1.3.1 with: path: ./package.json - name: Login to gitea Container Registry uses: docker/login-action@v3 with: registry: git.harmonylab.ovh username: admin password: Apslxnap12bn23 # Build the Docker image - name: Build the Docker image run: docker build . --file Dockerfile --tag $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:${{ steps.package-version.outputs.current-version}} - name: Ouput images run: docker images # Tag the Docker Images #- name: Tag the image for the private registry (git.wonderfamilly.fr) # run: docker tag $DOCKER_IMAGE_NAME:$RELEASE_VERSION $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:$RELEASE_VERSION - name: Create a latest image as well run: docker tag $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:${{ steps.package-version.outputs.current-version}} $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:latest # Push the images to the registry - name: Push the Docker image with version number run: docker push $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:${{ steps.package-version.outputs.current-version}} - name: Push the latest tag run: docker push $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:latest # Remove the local images - name: Remove the Docker image with version number run: docker rmi $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:${{ steps.package-version.outputs.current-version}} - name: Remove the Docker image with latest tag run: docker rmi $DOCKER_REGISTRY_URL/$DOCKER_REGISTRY_ORG/$DOCKER_IMAGE_NAME:latest - name: Trigger Dockploy deployment run: curl -fsSL $DOCKPLOY_WEBHOOK_URL - name: Notify success if: success() run: | curl -X POST \ -H "Content-Type: application/json" \ -d '{"content": "✅ Déploiement réussi pour *backend* !"}' \ $DISCORD_WEBHOOK_URL - name: Notify failure if: failure() run: | curl -X POST \ -H "Content-Type: application/json" \ -d '{"content": "❌ Échec du déploiement backend."}' \ $DISCORD_WEBHOOK_URL