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