From b6fc96d90af79d8ae8ec158449ef5340dc092cad Mon Sep 17 00:00:00 2001 From: Oskar Date: Thu, 21 Oct 2021 23:09:46 +0200 Subject: [PATCH] ci: update workflows (#3) * Update ci.yml * Delete auto-fix.yml --- .github/workflows/{auto-fix.yml => ci.yml} | 36 +++++++++++++++++----- .github/workflows/test.yml | 19 ------------ 2 files changed, 29 insertions(+), 26 deletions(-) rename .github/workflows/{auto-fix.yml => ci.yml} (54%) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/auto-fix.yml b/.github/workflows/ci.yml similarity index 54% rename from .github/workflows/auto-fix.yml rename to .github/workflows/ci.yml index 5ac6919..794a1f4 100644 --- a/.github/workflows/auto-fix.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,21 @@ -name: auto fix +name: CI on: push: branches: - - "**" + - main + + pull_request: jobs: - auto-fix: + ci: runs-on: ubuntu-latest + steps: - - name: Checkout + - name: Repo clone (go mod tidy / gofmt) + if: github.event_name != 'pull_request' uses: actions/checkout@v2 with: - persist-credentials: false fetch-depth: 0 - name: Set up Go @@ -21,27 +24,46 @@ jobs: 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 + - name: Tidy + if: github.event_name != 'pull_request' run: | go mod tidy git add . git diff-index --quiet HEAD || git commit -m "go mod tidy" - - name: gofmt + - 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: 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 20f100c..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: test - -on: - push: - pull_request: - -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.16 - - - name: Test - run: go test -v ./...