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 to GHCR
2+
3+ on :
4+ push :
5+ branches : [main, master]
6+ workflow_dispatch :
7+
8+ concurrency :
9+ group : ${{ github.workflow }}-${{ github.ref }}
10+ cancel-in-progress : true
11+
12+ env :
13+ REGISTRY : ghcr.io
14+ IMAGE_NAME : ${{ github.repository }}
15+
16+ jobs :
17+ build-and-push :
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 : Log in to GHCR
28+ uses : docker/login-action@v3
29+ with :
30+ registry : ${{ env.REGISTRY }}
31+ username : ${{ github.actor }}
32+ password : ${{ secrets.GITHUB_TOKEN }}
33+
34+ - name : Set up Docker Buildx
35+ uses : docker/setup-buildx-action@v3
36+
37+ - name : Extract metadata for Docker
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=sha,format=short
45+ type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
46+
47+ - name : Build and push Docker image
48+ uses : docker/build-push-action@v6
49+ with :
50+ context : .
51+ tags : ${{ steps.meta.outputs.tags }}
52+ labels : ${{ steps.meta.outputs.labels }}
53+ cache-from : type=gha
54+ cache-to : type=gha,mode=max
Original file line number Diff line number Diff line change 1+ _ *
2+ * .json *
3+ * .db
4+ * .env
You can’t perform that action at this time.
0 commit comments