File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 4040 - name : Build binary
4141 run : go build -o app
4242
43+ build :
44+ # Specify the OS for the runner
45+ runs-on : ubuntu-latest
46+
47+ # Grant write permissions to access repository contents and GitHub Container Registry
48+ permissions :
49+ contents : write
50+ packages : write
51+
52+ # Run this job only after the 'compile' job completes successfully
53+ needs : compile
54+ if : success()
55+
56+ steps :
57+ # Step 1: Checkout the repository code
58+ - name : Checkout code
59+ uses : actions/checkout@v4
60+
61+ # Step 2: Set up the Go environment (Go 1.22)
62+ - name : Set up Go
63+ uses : actions/setup-go@v5
64+ with :
65+ go-version : ' 1.22'
66+
67+ # Step 3: Log in to GitHub Container Registry (GHCR) using GitHub Actions token
68+ - name : Log in to GHCR
69+ uses : docker/login-action@v3
70+ with :
71+ registry : ghcr.io
72+ username : ${{ github.actor }} # GitHub username (actor triggering the workflow)
73+ password : ${{ secrets.GITHUB_TOKEN }} # Automatically provided GitHub token
74+
75+ # Step 4: Build the Docker image and tag it with the repository name and 'latest'
76+ - name : Build Docker image
77+ run : docker build -t ghcr.io/${{ github.repository }}:latest .
4378
79+ # Step 5: Push the Docker image to GitHub Container Registry
80+ - name : Push Docker image
81+ run : docker push ghcr.io/${{ github.repository }}:latest
You can’t perform that action at this time.
0 commit comments