Skip to content

Commit 56ac6a4

Browse files
Create go.yml
1 parent fb6b6d2 commit 56ac6a4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/go.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Go CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Go environment
20+
uses: actions/setup-go@v4
21+
with:
22+
go-version: '1.20'
23+
24+
- name: Cache Go modules
25+
uses: actions/cache@v3
26+
with:
27+
path: |
28+
~/.cache/go-build
29+
~/go/pkg/mod
30+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
31+
restore-keys: |
32+
${{ runner.os }}-go-
33+
34+
- name: Install dependencies
35+
run: go mod download
36+
37+
- name: Build application
38+
run: go build -v .
39+
40+
- name: Run tests
41+
run: go test -v ./...
42+
43+
- name: Docker login (if using Docker)
44+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
45+
46+
- name: Build Docker image
47+
run: docker build -t your-image-name .
48+
49+
- name: Push Docker image
50+
run: docker push your-image-name

0 commit comments

Comments
 (0)