Files
chromebrew/.github/workflows/Linter-Handoff.yml
Satadru Pramanik, DO, MPH, MEng 13640f5ed3 generate_prs_flip_draft_to_ready — (#12321)
* Flip draft PRs to ready from the Generate PRs workflow if there is an existing PR in draft and the workflow was not started with PR in Draft Mode selected.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust Linter Handoff workflow git update logic.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
2025-08-01 23:24:05 +00:00

111 lines
3.2 KiB
YAML

---
name: Linter-Handoff
on:
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
merge_group:
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }}
jobs:
debug:
if: ${{ ( github.repository_owner == 'chromebrew' ) }}
runs-on: ubuntu-24.04
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
handoff:
runs-on: ubuntu-24.04
outputs:
category: ${{ steps.changed-file-extensions.outputs.category }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Update branch
if: ${{ !contains(github.ref_name, '/merge') }}
run: |
git fetch origin
git checkout "${{ github.ref_name }}"
git reset --hard "origin/${{ github.ref_name }}"
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
- name: Get extensions of changed files
id: changed-file-extensions
run: |
category=
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
ext="${file##*.}"
case $ext in
md)
category+=" Markdown";;
rb)
category+=" Ruby";;
sh)
category+=" Bash";;
yml|yaml)
category+=" YAML";;
*)
echo "Unable to check syntax of $file.";;
esac
# In order for files such as bin/crew to be recognised
[[ "$(file -b $file | cut -d' ' -f1)" == "Ruby" ]] && category+=" Ruby"
done
echo "category=$category" >> $GITHUB_OUTPUT
# Github won't let us do this neatly, see https://github.com/orgs/community/discussions/25246
markdown:
needs: handoff
if: contains(needs.handoff.outputs.category, 'Markdown')
uses: ./.github/workflows/Markdown-lint.yml
secrets: inherit
ruby:
needs: handoff
if: contains(needs.handoff.outputs.category, 'Ruby')
uses: ./.github/workflows/Rubocop.yml
secrets: inherit
bash:
needs: handoff
if: contains(needs.handoff.outputs.category, 'Bash')
uses: ./.github/workflows/ShellCheck.yml
secrets: inherit
yaml:
needs: handoff
if: contains(needs.handoff.outputs.category, 'YAML')
uses: ./.github/workflows/YAMLlint.yml
secrets: inherit
action-yaml:
needs: handoff
if: contains(needs.handoff.outputs.category, 'YAML')
uses: ./.github/workflows/Actionlint.yml
secrets: inherit
linter-tests:
runs-on: ubuntu-24.04
needs:
- handoff
- markdown
- ruby
- bash
- yaml
- action-yaml
if: ${{ !cancelled() }}
steps:
- name: fail if linter jobs failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- run: echo "Linter jobs succeeded"