File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-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 :
6+ - main
7+ pull_request :
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ - name : Set up Docker Buildx
18+ uses : docker/setup-buildx-action@v2
19+
20+ - name : Build Docker image
21+ run : |
22+ docker build -t ghcr.io/${{ github.repository }}:${{ github.sha }} .
23+
24+ push :
25+ runs-on : ubuntu-latest
26+ needs : build
27+ if : github.ref == 'refs/heads/main'
28+
29+ steps :
30+ - name : Checkout code
31+ uses : actions/checkout@v3
32+
33+ - name : Log in to GitHub Container Registry
34+ uses : docker/login-action@v2
35+ with :
36+ registry : ghcr.io
37+ username : ${{ github.actor }}
38+ password : ${{ secrets.GITHUB_TOKEN }}
39+
40+ - name : Push Docker image
41+ run : |
42+ docker push ghcr.io/${{ github.repository }}:${{ github.sha }}
You can’t perform that action at this time.
0 commit comments