2021-10-21 21:09:46 +00:00
|
|
|
name: CI
|
2021-08-19 14:52:26 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-08-19 18:18:31 +00:00
|
|
|
branches:
|
2021-10-21 21:09:46 +00:00
|
|
|
- main
|
|
|
|
|
|
|
|
pull_request:
|
2021-08-19 14:52:26 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-10-21 21:09:46 +00:00
|
|
|
ci:
|
2021-08-19 14:52:26 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-10-21 21:09:46 +00:00
|
|
|
|
2021-08-19 14:52:26 +00:00
|
|
|
steps:
|
2021-10-21 21:09:46 +00:00
|
|
|
- name: Repo clone (go mod tidy / gofmt)
|
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v2
|
|
|
|
with:
|
|
|
|
go-version: 1.17
|
|
|
|
|
|
|
|
- name: Setup Git
|
2021-10-21 21:09:46 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
run: |
|
|
|
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
|
2021-10-21 21:09:46 +00:00
|
|
|
- name: Tidy
|
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
run: |
|
|
|
|
go mod tidy
|
|
|
|
git add .
|
|
|
|
git diff-index --quiet HEAD || git commit -m "go mod tidy"
|
|
|
|
|
2021-10-21 21:09:46 +00:00
|
|
|
- name: GoFmt
|
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
run: |
|
|
|
|
go fmt ./...
|
|
|
|
git add .
|
|
|
|
git diff-index --quiet HEAD || git commit -m "gofmt"
|
|
|
|
|
|
|
|
- name: Pull changes
|
2021-10-21 21:09:46 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
run: git pull -r
|
|
|
|
|
|
|
|
- name: Push changes
|
2021-10-21 21:09:46 +00:00
|
|
|
if: github.event_name != 'pull_request'
|
2021-08-19 14:52:26 +00:00
|
|
|
uses: ad-m/github-push-action@master
|
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
branch: ${{ github.ref }}
|
2021-10-21 21:09:46 +00:00
|
|
|
|
|
|
|
- name: Repo clone (test)
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: go test -v ./...
|
|
|
|
|
|
|
|
- name: Semantic Release
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: go-semantic-release/action@v1
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|