Feat: Add GitHub Actions Workflow for CI/CD (#21)
Add GitHub Actions Workflow for CI/CD (#21)
This commit is contained in:
parent
8be7e5c197
commit
42b391fe9b
10 changed files with 159 additions and 0 deletions
22
.github/actions/setup-go-and-deps/action.yml
vendored
Normal file
22
.github/actions/setup-go-and-deps/action.yml
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
name: Setup Go and Dependencies
|
||||||
|
description: 'Setup Go and Dependencies'
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
go-version-file:
|
||||||
|
description: 'The path to the go.mod file'
|
||||||
|
required: false
|
||||||
|
default: 'go.mod'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version-file: ${{ inputs.go-version-file }}
|
||||||
|
|
||||||
|
- name: Install Dependencies
|
||||||
|
shell: bash
|
||||||
|
run: go mod tidy
|
||||||
21
.github/workflows/build.yml
vendored
Normal file
21
.github/workflows/build.yml
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Go and dependencies
|
||||||
|
uses: ./.github/actions/setup-go-and-deps
|
||||||
|
- name: build
|
||||||
|
run: CGO_ENABLED=0 go build -o main .
|
||||||
|
|
||||||
|
- name: upload builded artifact
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: main-${{github.sha}}
|
||||||
|
path: main
|
||||||
14
.github/workflows/dependencies.yml
vendored
Normal file
14
.github/workflows/dependencies.yml
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deps:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Go and dependencies
|
||||||
|
uses: ./.github/actions/setup-go-and-deps
|
||||||
17
.github/workflows/deployment.yml
vendored
Normal file
17
.github/workflows/deployment.yml
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: download builded artifact
|
||||||
|
uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: main-${{github.sha}}
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
echo "Dummy Deploy..."
|
||||||
18
.github/workflows/lint.yml
vendored
Normal file
18
.github/workflows/lint.yml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: golang ci lint
|
||||||
|
uses: golangci/golangci-lint-action@v6
|
||||||
|
continue-on-error: true
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
args: --timeout 10m
|
||||||
|
|
||||||
|
|
||||||
34
.github/workflows/main.yml
vendored
Normal file
34
.github/workflows/main.yml
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
run-name: main workflow
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pre:
|
||||||
|
uses: ./.github/workflows/pre.yml
|
||||||
|
deps:
|
||||||
|
needs: pre
|
||||||
|
uses: ./.github/workflows/dependencies.yml
|
||||||
|
lint:
|
||||||
|
needs: deps
|
||||||
|
uses: ./.github/workflows/lint.yml
|
||||||
|
test:
|
||||||
|
needs: deps
|
||||||
|
uses: ./.github/workflows/test.yml
|
||||||
|
build:
|
||||||
|
needs: [test, lint]
|
||||||
|
uses: ./.github/workflows/build.yml
|
||||||
|
deploy:
|
||||||
|
needs: build
|
||||||
|
uses: ./.github/workflows/deployment.yml
|
||||||
14
.github/workflows/pre.yml
vendored
Normal file
14
.github/workflows/pre.yml
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pre:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: pre script
|
||||||
|
run: |
|
||||||
|
echo "Running pre script"
|
||||||
15
.github/workflows/test.yml
vendored
Normal file
15
.github/workflows/test.yml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
on: [workflow_call]
|
||||||
|
defaults:
|
||||||
|
run:
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Go and dependencies
|
||||||
|
uses: ./.github/actions/setup-go-and-deps
|
||||||
|
- name: test
|
||||||
|
run: go test -v ./...
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -21,3 +21,5 @@ go-base
|
||||||
|
|
||||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||||
*.out
|
*.out
|
||||||
|
|
||||||
|
main
|
||||||
2
.tool-versions
Normal file
2
.tool-versions
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
golang 1.18
|
||||||
|
golangci-lint 1.59.1
|
||||||
Loading…
Add table
Add a link
Reference in a new issue