Bump actions/github-script from 6 to 7 #3
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a golang project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go | |
name: Go | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
GIN_MODE: release | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Build | |
run: go build -v ./... | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Test coverage | |
run: | | |
go test -v ./... -cover -covermode=count -coverprofile=coverage.out | tee test_output.txt | |
go tool cover -func=coverage.out | bash scripts/coverage.sh > coverage.txt | |
go tool cover -html=coverage.out -o coverage.html | |
- name: Comment Coverage | |
uses: actions/github-script@v7 | |
continue-on-error: true | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const coverage = fs.readFileSync('coverage.txt', 'utf8'); | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: coverage | |
}); | |
update_deps: | |
runs-on: ubuntu-latest | |
needs: test | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Set Up git | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Update dependencies | |
run: go mod tidy | |
- name: Commit changes | |
continue-on-error: true | |
run: | | |
git add go.mod go.sum | |
git commit -m "Update dependencies" || exit | |
git push | |
update_openapi: | |
runs-on: ubuntu-latest | |
needs: test | |
if: ${{ github.event_name == 'push' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.23' | |
- name: Set Up git | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "github-actions[bot]" | |
- name: Install dependencies | |
run: | | |
go mod download | |
go install github.com/swaggo/swag/cmd/swag@latest | |
- name: Update OpenAPI | |
run: swag init ./main.go | |
- name: Commit changes | |
continue-on-error: true | |
run: | | |
git add docs/swagger.yaml | |
git commit -m "Update OpenAPI" || exit | |
git push | |