v1.9.0 #120
Workflow file for this run
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: Build and Push Docker Images | |
| on: | |
| # Build on push to develop branch (nightly/unstable builds) | |
| push: | |
| branches: ['develop'] | |
| # Only build on release for production deployments | |
| release: | |
| types: [published] | |
| # Build on PR to validate changes (no push) | |
| pull_request: | |
| branches: ['main', 'develop'] | |
| # Manual trigger for testing | |
| workflow_dispatch: | |
| inputs: | |
| platforms: | |
| description: 'Target platforms (comma-separated)' | |
| required: false | |
| default: 'linux/amd64' | |
| type: string | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| include: | |
| - context: ./backend | |
| image: backend | |
| - context: ./frontend | |
| image: frontend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Read VERSION file | |
| id: version | |
| run: echo "version=$(cat VERSION)" >> $GITHUB_OUTPUT | |
| - name: Determine version type | |
| id: version_type | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [[ "$VERSION" =~ -(beta|alpha|rc)\. ]]; then | |
| echo "is_prerelease=true" >> $GITHUB_OUTPUT | |
| echo "prerelease_type=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | |
| else | |
| echo "is_prerelease=false" >> $GITHUB_OUTPUT | |
| echo "prerelease_type=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }} | |
| tags: | | |
| # Branch-based tags | |
| type=ref,event=branch | |
| type=ref,event=pr | |
| # Develop branch gets 'develop' and 'nightly' tags | |
| type=raw,value=develop,enable=${{ github.ref == 'refs/heads/develop' }} | |
| type=raw,value=nightly,enable=${{ github.ref == 'refs/heads/develop' }} | |
| # Version tags for releases | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| # SHA for traceability | |
| type=sha,prefix=sha- | |
| # 'latest' tag only for stable releases (not prereleases) | |
| type=raw,value=latest,enable=${{ github.event_name == 'release' && steps.version_type.outputs.is_prerelease == 'false' }} | |
| # 'beta' tag for prerelease versions | |
| type=raw,value=beta,enable=${{ github.event_name == 'release' && steps.version_type.outputs.is_prerelease == 'true' }} | |
| # Explicit version tag from VERSION file | |
| type=raw,value=${{ steps.version.outputs.version }},enable=${{ github.event_name == 'release' }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.context }} | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| COMMIT_SHA=${{ github.sha }} | |
| BUILD_DATE=${{ github.event.head_commit.timestamp }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| platforms: ${{ inputs.platforms || 'linux/amd64' }} | |
| - name: Image digest | |
| run: echo ${{ steps.meta.outputs.digest }} | |
| - name: Summary | |
| run: | | |
| echo "## 🐳 Docker Image Built" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Image:** \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tags:**" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY |