name: Docker Build and Publish on: push: branches: ["main"] tags: ["v*"] env: REGISTRY: git.maxboeer.com IMAGE_NAME: components-elixir jobs: docker-build: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }} tags: | # Keep a moving branch tag (e.g., main) type=ref,event=branch # Version tag on releases (e.g., v1.2.3) type=ref,event=tag # Snapshot tag for commits on the default branch (e.g., snapshot-) type=raw,value=snapshot-{{sha}},enable={{is_default_branch}} # Move "latest" only when building from a tag type=raw,value=latest,enable={{is_tag}} - name: Log in to Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITEAX_TOKEN }} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} # GitHub Actions cache needs proper runner configuration # https://docs.gitea.com/usage/actions/act-runner#configuring-cache-when-starting-a-runner-using-docker-image cache-from: type=gha cache-to: type=gha,mode=max build-args: | ELIXIR_VERSION=1.15 OTP_VERSION=26 DEBIAN_VERSION=bookworm-slim - name: Generate summary run: | echo "## Docker Build Summary" >> $GITHUB_STEP_SUMMARY echo "- **Image**: \`${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}\`" >> $GITHUB_STEP_SUMMARY echo "- **Platform**: linux/amd64" >> $GITHUB_STEP_SUMMARY echo "- **Tags**: " >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY if [[ "${{ github.ref_type }}" == "tag" ]]; then echo "- **Build Type**: Release build for tag \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY else echo "- **Build Type**: Snapshot build for branch \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY fi echo "- **Commit**: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY