Skip to content

Commit

Permalink
feat(#19): corrected the Check Runs code to show whether the lint is …
Browse files Browse the repository at this point in the history
…with success or not

Signed-off-by: Felipe Rios <[email protected]>
  • Loading branch information
rios0rios0 committed Feb 8, 2024
1 parent 688d810 commit fa29f85
Showing 1 changed file with 23 additions and 38 deletions.
61 changes: 23 additions & 38 deletions github/golang/stages/10-code-check/golangci-lint/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:"}

0 comments on commit fa29f85

Please sign in to comment.