1+ name : Docker Build
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ tags : [ 'v*' ]
7+ pull_request :
8+ branches : [ main ]
9+
10+ env :
11+ REGISTRY : ghcr.io
12+ IMAGE_NAME : ${{ github.repository }}
13+
14+ jobs :
15+ build :
16+ runs-on : ubuntu-latest
17+ permissions :
18+ contents : read
19+ packages : write
20+
21+ steps :
22+ - name : " node-cleanup"
23+ run : |
24+ sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL
25+ df -h
26+
27+
28+ - name : Checkout repository
29+ uses : actions/checkout@v4
30+
31+ - name : Log in to Container Registry
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 : Extract metadata
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=semver,pattern={{major}}.{{minor}}
49+ type=raw,value=latest,enable={{is_default_branch}}
50+
51+ - name : Set up Docker Buildx
52+ uses : docker/setup-buildx-action@v3
53+
54+ - run : df -h
55+
56+ - name : Build and push Docker image
57+ uses : docker/build-push-action@v5
58+ with :
59+ context : .
60+ push : ${{ github.event_name != 'pull_request' }}
61+ tags : ${{ steps.meta.outputs.tags }}
62+ labels : ${{ steps.meta.outputs.labels }}
63+ cache-from : type=gha
64+ cache-to : type=gha,mode=max
0 commit comments