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

90 lines
2.2 KiB
YAML
Raw Permalink 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-04 11:05:41 +00:00
branches:
2021-09-02 20:21:17 +00:00
- 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
2021-07-14 09:52:50 +00:00
steps:
2022-06-02 19:30:26 +00:00
- name: Checkout (go mod tidy / gofmt)
2021-09-02 20:21:17 +00:00
if: github.event_name != 'pull_request'
uses: actions/checkout@v3
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@v3
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: |
2022-05-13 07:02:40 +00:00
git config --local user.email "rm99iv9s@duck.com"
git config --local user.name "MedzikUserBot"
2021-08-27 17:25:28 +00:00
- 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: |
2021-09-04 11:05:41 +00:00
go mod tidy -go=1.17
2021-08-27 17:25:28 +00:00
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 }}
2022-06-02 19:30:26 +00:00
- name: Checkout (build)
uses: actions/checkout@v3
2021-08-18 17:19:07 +00:00
with:
2021-10-15 17:00:54 +00:00
fetch-depth: 0
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2021-07-14 09:52:50 +00:00
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
2021-07-14 09:52:50 +00:00
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@v3
2021-08-18 16:38:49 +00:00
with:
path: dist/*.tar*
retention-days: 10