|
| 1 | +# This workflow deploys the production Docker image to Docker Hub |
| 2 | + |
| 3 | +name: Publish to Docker Hub |
| 4 | + |
| 5 | +on: |
| 6 | + release: |
| 7 | + types: [published] |
| 8 | + |
| 9 | +env: |
| 10 | + REGISTRY: docker.io |
| 11 | + IMAGE_NAME: weaponsforge/gemini-cli |
| 12 | + |
| 13 | +jobs: |
| 14 | + docker-build-push: |
| 15 | + name: Build and Push Docker Image |
| 16 | + if: github.event.release.target_commitish == 'master' && vars.DOCKERHUB_USERNAME != '' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + packages: write |
| 21 | + steps: |
| 22 | + - name: Checkout the repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + ref: ${{ github.event.release.tag_name }} |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v3 |
| 29 | + |
| 30 | + - name: Log in to Docker Hub |
| 31 | + uses: docker/login-action@v3 |
| 32 | + with: |
| 33 | + registry: ${{ env.REGISTRY }} |
| 34 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 35 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 36 | + |
| 37 | + - name: Extract metadata |
| 38 | + id: meta |
| 39 | + uses: docker/metadata-action@v5 |
| 40 | + with: |
| 41 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 42 | + tags: | |
| 43 | + type=ref,event=branch |
| 44 | + type=ref,event=pr |
| 45 | + type=semver,pattern={{version}} |
| 46 | + type=semver,pattern={{major}}.{{minor}} |
| 47 | + type=raw,value=latest,enable={{is_default_branch}} |
| 48 | +
|
| 49 | + - name: Build and push Docker image |
| 50 | + uses: docker/build-push-action@v5 |
| 51 | + with: |
| 52 | + context: . |
| 53 | + file: ./Dockerfile |
| 54 | + platforms: linux/amd64,linux/arm64 |
| 55 | + push: true |
| 56 | + tags: ${{ steps.meta.outputs.tags }} |
| 57 | + labels: ${{ steps.meta.outputs.labels }} |
| 58 | + cache-from: type=gha |
| 59 | + cache-to: type=gha,mode=max |
| 60 | + build-args: | |
| 61 | + BUILDKIT_INLINE_CACHE=1 |
| 62 | +
|
| 63 | + - name: Scan image for vulnerabilities |
| 64 | + uses: aquasecurity/[email protected] |
| 65 | + with: |
| 66 | + image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} |
| 67 | + format: 'sarif' |
| 68 | + output: 'trivy-results.sarif' |
| 69 | + |
| 70 | + - name: Upload Trivy scan results to GitHub Security tab |
| 71 | + uses: github/codeql-action/upload-sarif@v3 |
| 72 | + if: always() |
| 73 | + with: |
| 74 | + sarif_file: 'trivy-results.sarif' |
0 commit comments