Skip to content

refactor: replace logger #498

refactor: replace logger

refactor: replace logger #498

Workflow file for this run

name: Test, Lint
on:
push:
branches:
- "*"
tags:
- "v*"
pull_request:
env:
GO_VERSION: "1.23"
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run tests
run: make test
- uses: codecov/codecov-action@v4
with:
file: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Run linter
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Run linter
uses: golangci/golangci-lint-action@v6
with:
version: latest
skip-cache: true
trigger-release:
name: Trigger release workflow
needs: [test, lint]
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- name: Trigger release workflow
uses: actions/github-script@v7
with:
# need different token, RELEASE_TOKEN belongs to digineobot
github-token: ${{ secrets.RELEASE_TOKEN }}
script: |
const trigger = (ref, type) => github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'release.yml',
ref,
inputs: {
goreleaser: type === 'release' ? 'true' : 'false',
releaseType: type,
}
})
// 'refs/heads/master' or 'refs/tags/...'
const [_refs, kind, ref, _rest] = context.ref.split('/', 4)
if (kind === 'heads') {
await trigger(ref, "dev")
console.log(`triggered dev-release for ${ref}`)
return
}
if (kind === 'tags' && ref.startsWith('v')) {
await trigger(ref, "release")
console.log(`triggered release for ${ref}`)
return
}
console.warn(`unexpected git ref: ${context.ref} - skipping`)