-
Notifications
You must be signed in to change notification settings - Fork 2
45 lines (41 loc) · 1.12 KB
/
account-ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: account-ci
# work on path /cmd/account
on:
push:
paths:
- 'cmd/account/**'
- '.github/workflows/account-ci.yaml'
branches:
- main
pull_request:
paths:
- 'cmd/account/**'
- '.github/workflows/account-ci.yaml'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.19
- name: Build account Binary Executable
run: |
go mod tidy
cd cmd/account
go mod tidy
go build -ldflags="-s -w" -o account
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./cmd/account
file: ./cmd/account/Dockerfile
push: ${{ github.ref == 'refs/heads/main' }}
tags: ${{ secrets.DOCKERHUB_USERNAME || 'account' }}/account:latest