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 : Build and Push Docker Image
2+
3+ on :
4+ push :
5+ branches : [main]
6+ paths-ignore :
7+ - ' *.md'
8+ - ' LICENSE'
9+ pull_request :
10+ branches : [main]
11+
12+ env :
13+ REGISTRY : ghcr.io
14+ IMAGE_NAME : ${{ github.repository }}
15+
16+ jobs :
17+ build :
18+ runs-on : ubuntu-latest
19+ permissions :
20+ contents : read
21+ packages : write
22+
23+ steps :
24+ - name : Checkout repository
25+ uses : actions/checkout@v4
26+
27+ - name : Set up Docker Buildx
28+ uses : docker/setup-buildx-action@v3
29+
30+ - name : Log in to Container Registry
31+ if : github.event_name != 'pull_request'
32+ uses : docker/login-action@v3
33+ with :
34+ registry : ${{ env.REGISTRY }}
35+ username : ${{ github.actor }}
36+ password : ${{ secrets.GITHUB_TOKEN }}
37+
38+ - name : Extract metadata
39+ id : meta
40+ uses : docker/metadata-action@v5
41+ with :
42+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+ tags : |
44+ type=raw,value=latest,enable={{is_default_branch}}
45+ type=sha,prefix=
46+ type=ref,event=pr
47+
48+ - name : Build and push
49+ uses : docker/build-push-action@v6
50+ with :
51+ context : .
52+ push : ${{ github.event_name != 'pull_request' }}
53+ tags : ${{ steps.meta.outputs.tags }}
54+ labels : ${{ steps.meta.outputs.labels }}
55+ cache-from : type=gha
56+ cache-to : type=gha,mode=max
You can’t perform that action at this time.
0 commit comments