Skip to content

Commit 3f212f6

Browse files
committed
wip: deploy to docker hub on push
1 parent aff29d8 commit 3f212f6

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)