mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
91 lines
2.3 KiB
YAML
91 lines
2.3 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
ci:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Repo clone (go mod tidy / gofmt)
|
|
if: github.event_name != 'pull_request'
|
|
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
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git config --local user.name "github-actions[bot]"
|
|
|
|
- name: Tidy
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
go mod tidy -go=1.17
|
|
git add .
|
|
git diff-index --quiet HEAD || git commit -m "go mod tidy"
|
|
|
|
- name: GoFmt
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
go fmt ./...
|
|
git add .
|
|
git diff-index --quiet HEAD || git commit -m "gofmt"
|
|
|
|
- name: Pull changes
|
|
if: github.event_name != 'pull_request'
|
|
run: git pull -r
|
|
|
|
- name: Push changes
|
|
if: github.event_name != 'pull_request'
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: ${{ github.ref }}
|
|
|
|
- name: Semantic Release
|
|
if: github.event_name != 'pull_request'
|
|
uses: go-semantic-release/action@v1
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Repo clone (build)
|
|
uses: actions/checkout@v2
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Login to DockerHub
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Run GoReleaser
|
|
uses: goreleaser/goreleaser-action@v2
|
|
with:
|
|
distribution: goreleaser
|
|
version: latest
|
|
args: release --rm-dist
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
path: dist/*.tar*
|
|
retention-days: 10
|