name: Build and Push Docker Image on: push: branches: [ main ] tags: [ 'v*' ] pull_request: branches: [ main ] env: REGISTRY: ghcr.io IMAGE_NAME: skylanix/mamiehenriette jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=raw,value=latest,enable={{is_default_branch}} labels: | org.opencontainers.image.title=${{ github.repository }} org.opencontainers.image.description=Bot multi-plateformes Discord/Twitch/YouTube pour la communauté STEvE org.opencontainers.image.source=https://github.com/${{ github.repository }} org.opencontainers.image.url=https://github.com/${{ github.repository }} org.opencontainers.image.licenses=GPL-3.0 - name: Build and push uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - name: Test container startup run: | echo "Testing if the container starts successfully..." docker run --rm -d --name test-container -p 5001:5000 \ -e TZ=Europe/Paris \ -e ENABLE_ZABBIX=false \ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest # Wait for container to be ready sleep 10 # Check if container is still running if docker ps | grep test-container; then echo "✅ Container started successfully" docker logs test-container else echo "❌ Container failed to start" docker logs test-container exit 1 fi # Stop the test container docker stop test-container