rename renovate-config to workflow-config #206
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
name: linter | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
concurrency: | |
group: linter-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
check_changes: | |
uses: patmoreau/workflow-config/.github/workflows/check-changes-action.yml@main | |
with: | |
file_patterns: ${{ vars.CODE_FILE_PATTERNS }} | |
csharp: | |
runs-on: ubuntu-latest | |
needs: check_changes | |
if: ${{ needs.check_changes.outputs.code_was_changed == 'true' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: ./global.json | |
- name: Lint C# files with dotnet format | |
id: lint | |
run: dotnet format --severity error --verbosity diagnostic --report ./linter-report || true | |
- name: Save report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dotnet-format-report | |
path: ./linter-report/* | |
- name: Check for errors | |
if: ${{ steps.lint.outcome != 'success' }} | |
run: echo "::error::dotnet format found issues in the code. Please fix them." | |
required_check: | |
needs: [check_changes, csharp] | |
runs-on: ubuntu-latest | |
if: always() && needs.check_changes.result == 'success' | |
steps: | |
- name: Check conditions and set conclusion | |
id: check_conditions | |
run: | | |
if [[ "${{ needs.check_changes.outputs.code_was_changed }}" == "false" ]] || [[ "${{ needs.csharp.result }}" == "success" ]]; then | |
echo "conclusion=success" >> $GITHUB_OUTPUT | |
else | |
echo "conclusion=failure" >> $GITHUB_OUTPUT | |
fi | |
- name: Create check run | |
id: create_check_run | |
uses: actions/github-script@v7.0.1 | |
with: | |
script: | | |
const head_sha = context.payload.pull_request ? context.payload.pull_request.head.sha : context.sha; | |
const { data: { id: check_run_id } } = await github.rest.checks.create({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'linter-completed', | |
head_sha: head_sha, | |
status: 'completed', | |
conclusion: '${{ steps.check_conditions.outputs.conclusion }}' | |
}); | |
return check_run_id; |