modified dockerfile #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Go CI/CD | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*.*.*' | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.22' | |
- name: Cache Go modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
~/go/cache | |
key: ${{ runner.os }}-go-${{ hashFiles('server/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ hashFiles('server/go.sum') }} | |
${{ runner.os }}-go- | |
- name: Install dependencies | |
working-directory: server | |
run: go mod download | |
- name: Run vet | |
working-directory: server | |
run: go vet ./... | |
- name: Run tests | |
working-directory: server | |
run: go test -v ./... | |
- name: Build | |
working-directory: server | |
run: go build -v -o ./bin/myapp ./main.go | |
lint: | |
runs-on: ubuntu-latest | |
needs: build-test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.22' | |
- name: Install golangci-lint | |
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 | |
- name: Run golangci-lint | |
working-directory: server | |
run: golangci-lint run ./... | |
release: | |
runs-on: ubuntu-latest | |
needs: [build-test, lint] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.22' | |
- name: Build | |
working-directory: server | |
run: go build -v -o ./bin/myapp ./main.go | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
if: success() | |
with: | |
files: ./server/bin/myapp | |
env: | |
GITHUB_TOKEN: ${{ secrets.PIPE_TOKEN }} |