File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed 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+ pull_request :
7+ branches : [main]
8+
9+ env :
10+ REGISTRY : ghcr.io
11+ IMAGE_NAME : ${{ github.repository }}
12+
13+ jobs :
14+ build-and-push :
15+ runs-on : ubuntu-latest
16+ permissions :
17+ contents : read
18+ packages : write
19+
20+ steps :
21+ - uses : actions/checkout@v4
22+
23+ - name : Log in to GitHub Container Registry
24+ if : github.event_name == 'push'
25+ uses : docker/login-action@v3
26+ with :
27+ registry : ${{ env.REGISTRY }}
28+ username : ${{ github.actor }}
29+ password : ${{ secrets.GITHUB_TOKEN }}
30+
31+ - name : Read version from package.json
32+ id : version
33+ run : echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
34+
35+ - name : Extract metadata
36+ id : meta
37+ uses : docker/metadata-action@v5
38+ with :
39+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+ tags : |
41+ type=raw,value=${{ steps.version.outputs.version }},enable={{is_default_branch}}
42+ type=sha
43+ type=raw,value=latest,enable={{is_default_branch}}
44+
45+ - name : Build and push
46+ uses : docker/build-push-action@v6
47+ with :
48+ context : .
49+ push : ${{ github.event_name == 'push' }}
50+ tags : ${{ steps.meta.outputs.tags }}
51+ labels : ${{ steps.meta.outputs.labels }}
You can’t perform that action at this time.
0 commit comments