fix(tests): resolve flaky Testcontainers lifecycle causing intermitte… #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Feature Branch Docker | |
| on: | |
| push: | |
| branches-ignore: | |
| - main | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-and-push: | |
| name: Build & push Docker images | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Sanitize branch name for Docker tag | |
| id: branch | |
| run: | | |
| RAW="${GITHUB_REF_NAME}" | |
| SANITIZED=$(echo "$RAW" | sed 's/[^a-zA-Z0-9._-]/-/g' | sed 's/^-//;s/-$//' | cut -c1-128) | |
| echo "TAG=$SANITIZED" >> "$GITHUB_OUTPUT" | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push frontend image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./frontend | |
| file: ./frontend/Dockerfile.prod | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/frontend:${{ steps.branch.outputs.TAG }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and push backend image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./backend | |
| file: ./backend/Dockerfile.prod | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/backend:${{ steps.branch.outputs.TAG }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Summary | |
| run: | | |
| echo "### 🐳 Docker images pushed" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Service | Image |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "|---------|-------|" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Frontend | \`ghcr.io/${{ github.repository }}/frontend:${{ steps.branch.outputs.TAG }}\` |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "| Backend | \`ghcr.io/${{ github.repository }}/backend:${{ steps.branch.outputs.TAG }}\` |" >> "$GITHUB_STEP_SUMMARY" | |
| echo "" >> "$GITHUB_STEP_SUMMARY" | |
| echo "Pull with:" >> "$GITHUB_STEP_SUMMARY" | |
| echo "\`\`\`bash" >> "$GITHUB_STEP_SUMMARY" | |
| echo "docker pull ghcr.io/${{ github.repository }}/frontend:${{ steps.branch.outputs.TAG }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "docker pull ghcr.io/${{ github.repository }}/backend:${{ steps.branch.outputs.TAG }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "\`\`\`" >> "$GITHUB_STEP_SUMMARY" |