go-pingbot/.github/workflows/ci.yml

83 lines
2.0 KiB
YAML
Raw Normal View History

2021-08-27 17:25:28 +00:00
name: CI
2021-07-14 09:52:50 +00:00
on:
push:
2021-09-02 20:21:17 +00:00
branches:
- main
2021-08-18 16:38:49 +00:00
pull_request:
2021-07-14 09:52:50 +00:00
permissions:
contents: write
jobs:
2021-08-27 17:25:28 +00:00
ci:
2021-07-14 09:52:50 +00:00
runs-on: ubuntu-latest
steps:
2021-09-02 20:21:17 +00:00
- name: Checkout v1
if: github.event_name != 'pull_request'
2021-07-14 09:52:50 +00:00
uses: actions/checkout@v2
2021-08-01 17:43:59 +00:00
with:
2021-08-17 21:03:04 +00:00
fetch-depth: 0
2021-07-14 09:52:50 +00:00
- name: Set up Go
uses: actions/setup-go@v2
with:
2021-08-17 21:03:04 +00:00
go-version: 1.17
2021-08-27 17:25:28 +00:00
- name: Setup Git
2021-09-02 20:21:17 +00:00
if: github.event_name != 'pull_request'
2021-08-27 17:25:28 +00:00
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: tidy
2021-09-02 20:16:11 +00:00
if: github.event_name != 'pull_request'
2021-08-27 17:25:28 +00:00
run: |
go mod tidy
git add .
git diff-index --quiet HEAD || git commit -m "go mod tidy"
- name: gofmt
2021-09-02 20:16:11 +00:00
if: github.event_name != 'pull_request'
2021-08-27 17:25:28 +00:00
run: |
go fmt ./...
git add .
git diff-index --quiet HEAD || git commit -m "gofmt"
- name: Pull changes
2021-09-02 20:16:11 +00:00
if: github.event_name != 'pull_request'
2021-08-27 17:25:28 +00:00
run: git pull -r
- name: Push changes
2021-09-02 20:16:11 +00:00
if: github.event_name != 'pull_request'
2021-08-27 17:25:28 +00:00
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
2021-08-07 20:13:41 +00:00
- name: Semantic Release
2021-08-18 16:38:49 +00:00
if: github.event_name != 'pull_request'
2021-08-07 20:13:41 +00:00
uses: go-semantic-release/action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
2021-09-02 20:21:17 +00:00
- name: Checkout v2
2021-08-18 17:11:40 +00:00
uses: actions/checkout@v2
2021-08-18 17:19:07 +00:00
with:
fetch-depth: '0'
2021-07-14 09:52:50 +00:00
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-08-18 16:38:49 +00:00
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
path: dist/*.tar*
retention-days: 10