diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7c20616..840e7c9 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: go: - - 1.19 + - 1.21.3 steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/go-lint.yml b/.github/workflows/go-lint.yml index ad6a176..11bf69b 100644 --- a/.github/workflows/go-lint.yml +++ b/.github/workflows/go-lint.yml @@ -32,7 +32,7 @@ jobs: - name: Setup Go Environment uses: actions/setup-go@v1 with: - go-version: '1.19.2' + go-version: '1.21.3' - name: check gofmt run: | diffs=`gofmt -l . | wc -l` diff --git a/.github/workflows/today.yaml b/.github/workflows/today.yaml new file mode 100644 index 0000000..0d27966 --- /dev/null +++ b/.github/workflows/today.yaml @@ -0,0 +1,55 @@ +name: "leetcode-question-today" + +on: + schedule: + - cron: "0 1 * * *" # beijing 9am. + workflow_dispatch: + +jobs: + today: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Checkout External Go Repo + uses: actions/checkout@v2 + with: + repository: 'cloud-org/leetcode-question-today' + path: 'today' + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.21.3 + + - name: run cmd + working-directory: ./today + run: | + go mod tidy + go build -o ./main + ./main > run.log 2>&1 + + - name: Parse log and create issue + uses: actions/github-script@v5 + with: + script: | + const fs = require('fs'); + const path = require('path'); + const logPath = path.join(process.env.GITHUB_WORKSPACE, 'today','run.log'); + const logContent = fs.readFileSync(logPath, 'utf8'); + const lines = logContent.split('\n'); + const titleIndex = lines.findIndex(line => line.startsWith('Title: ')); + if (titleIndex !== -1) { + const title = lines[titleIndex]; + const body = lines.slice(titleIndex + 1, titleIndex + 5).join('\n'); + github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: title, + body: body, + labels: ['leetcode'] + }); + } diff --git a/go.mod b/go.mod index 1fea736..3d4101b 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,16 @@ module algorithm -go 1.19 +go 1.21 require ( github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 - github.com/kr/pretty v0.2.1 // indirect github.com/stretchr/testify v1.6.1 ) + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/kr/pretty v0.2.1 // indirect + github.com/kr/text v0.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +)