-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#19): corrected the Check Runs code to show whether the lint is …
…with success or not Signed-off-by: Felipe Rios <[email protected]>
- Loading branch information
1 parent
688d810
commit fa29f85
Showing
1 changed file
with
23 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,50 +4,35 @@ on: | |
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: 'actions/checkout@v3' | ||
- uses: 'rios0rios0/pipelines/github/golang/abstracts/scripts-repo@feat/#19' | ||
- id: 'get-pr-details' | ||
uses: 'actions/github-script@v7' | ||
with: | ||
script: | | ||
const { data: pr } = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: ${{ github.event.number }} | ||
}); | ||
return pr.head.sha; | ||
result-encoding: 'string' | ||
- id: 'create-check-run' | ||
uses: 'actions/github-script@v7' | ||
with: | ||
script: | | ||
const { data: checkRun } = await github.rest.checks.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
name: 'custom-check', | ||
head_sha: ${{ steps.get-pr-details.outputs.result }}, | ||
status: 'in_progress', | ||
output: { | ||
title: 'Custom Check', | ||
summary: 'The check is in progress...' | ||
} | ||
}); | ||
return checkRun.id; | ||
result-encoding: 'string' | ||
#- uses: 'actions/checkout@v3' | ||
#- uses: 'rios0rios0/pipelines/github/golang/abstracts/scripts-repo@feat/#19' | ||
#- id: 'golangci_lint' | ||
# run: $SCRIPTS_DIR/global/scripts/golangci-lint/run.sh || echo "EXIT_CODE=$?" >> $GITHUB_ENV && exit $EXIT_CODE | ||
# shell: 'bash' | ||
# continue-on-error: true | ||
- uses: 'actions/github-script@v7' | ||
- name: Get check runs using actions/github-script | ||
uses: actions/github-script@v7 | ||
id: get_check_runs | ||
with: | ||
script: | | ||
await github.rest.checks.update({ | ||
const { data: prData } = await github.rest.pulls.get({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.issue.number | ||
}); | ||
const { data: checkRunsData } = await github.rest.checks.listForRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
check_run_id: ${{ steps.create-check-run.outputs.result }}, | ||
conclusion: 'success', | ||
output: { | ||
title: 'Custom Check', | ||
summary: "golangci-lint had detected issues in the code ($EXIT_CODE) :x:" | ||
} | ||
ref: prData.head.sha | ||
}); | ||
return checkRunsData; | ||
- name: Print check runs | ||
run: echo "The check runs are ${{ steps.get_check_runs.outputs.result }}" | ||
shell: 'bash' | ||
#- uses: 'LouisBrunner/[email protected]' | ||
# with: | ||
# name: 'code-check > style:golangci-lint' | ||
# token: '${{ github.token }}' | ||
# conclusion: "${{ env.EXIT_CODE != 0 && 'failure' || 'success' }}" | ||
# output: | | ||
# {"summary":"golangci-lint had detected issues in the code (${{ env.EXIT_CODE }}) :x:"} |