File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ # It automatically builds your Docker image and pushes it to GHCR
2+ name : Build and Push Docker Image
3+
4+ # We will run this workflow every time you push to the 'main' branch
5+ on :
6+ push :
7+ branches : [ "main" ]
8+
9+ jobs :
10+ build-and-push :
11+ runs-on : ubuntu-latest # Use a standard GitHub-hosted runner
12+ permissions :
13+ contents : read
14+ packages : write # Give the job permission to write to GHCR
15+
16+ steps :
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+
20+ - name : Log in to GitHub Container Registry
21+ uses : docker/login-action@v3
22+ with :
23+ registry : ghcr.io
24+ username : ${{ github.actor }}
25+ password : ${{ secrets.GITHUB_TOKEN }}
26+
27+ - name : Build and push Docker image
28+ uses : docker/build-push-action@v5
29+ with :
30+ context : .
31+ file : ./Dockerfile
32+ push : true # Push the image after building
33+ tags : |
34+ ghcr.io/${{ github.repository }}:latest
35+ ghcr.io/${{ github.repository }}:${{ github.sha }}
You can’t perform that action at this time.
0 commit comments