File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Docker Image CI
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ workflow_dispatch :
7+ inputs :
8+ branch :
9+ description : ' Branch to run the workflow on'
10+ required : false
11+ release :
12+ types :
13+ - created
14+
15+ jobs :
16+ build-and-push :
17+ runs-on : ubuntu-latest
18+ permissions :
19+ contents : read
20+ packages : write
21+
22+ steps :
23+ - name : Checkout code
24+ uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0 # Saves time by not fetching other branches
27+
28+ - name : Set up Docker Buildx
29+ uses : docker/setup-buildx-action@v3
30+
31+ - name : Login to GitHub Container Registry
32+ uses : docker/login-action@v3
33+ with :
34+ registry : ghcr.io
35+ username : ${{ github.repository_owner }}
36+ password : ${{ secrets.GITHUB_TOKEN }}
37+
38+ - name : Set lowercase repository name
39+ run : |
40+ echo "REPO_LOWER=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
41+
42+ - name : Build and push Docker image
43+ id : docker_build
44+ uses : docker/build-push-action@v6
45+ with :
46+ context : .
47+ push : true
48+ tags : ghcr.io/${{ env.REPO_LOWER }}:latest
49+ cache-from : type=gha
50+ cache-to : type=gha,mode=max
You can’t perform that action at this time.
0 commit comments