SUPINT-2380: nuxeo admin console web scripts works #20
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: Check PR Description and Checkboxes | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
jobs: | |
check-pr-body: | |
runs-on: ubuntu-latest | |
outputs: | |
run_lint: ${{ steps.check.outputs.run_lint }} | |
run_build: ${{ steps.check.outputs.run_build }} | |
run_utest: ${{ steps.check.outputs.run_utest }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Add default PR Description if not present | |
id: add-description | |
run: | | |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH") | |
# Add default description if it doesn't exist | |
if ! echo "$PR_BODY" | grep -q '### Tasks'; then | |
echo "### Tasks" > pr_description.md | |
echo "- [ ] Run Lint" >> pr_description.md | |
echo "- [ ] Run Build" >> pr_description.md | |
echo "- [ ] Run Unit Tests" >> pr_description.md | |
echo "" >> pr_description.md # Add a blank line | |
echo "Automatically added default tasks checklist for PR." >> pr_description.md | |
git add pr_description.md | |
git commit -m "Add default PR description" | |
git push origin HEAD:$GITHUB_REF | |
fi | |
- name: Update PR Description | |
if: steps.add-description.outputs.exit_code == '0' # Only update description if default was added | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
commit-message: Update PR Description | |
title: Update PR Description | |
body: | | |
Automatically added default tasks checklist for PR. | |
branch: add-pr-description | |
base: ${{ github.head_ref }} | |
files: | | |
pr_description.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Check PR body for checkboxes | |
id: check | |
run: | | |
PR_BODY=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH") | |
if echo "$PR_BODY" | grep -q '\- \[x\] Run Lint'; then | |
echo "run_lint=true" >> $GITHUB_ENV | |
echo "::set-output name=run_lint::true" | |
else | |
echo "run_lint=false" >> $GITHUB_ENV | |
echo "::set-output name=run_lint::false" | |
fi | |
if echo "$PR_BODY" | grep -q '\- \[x\] Run Build'; then | |
echo "run_build=true" >> $GITHUB_ENV | |
echo "::set-output name=run_build::true" | |
else | |
echo "run_build=false" >> $GITHUB_ENV | |
echo "::set-output name=run_build::false" | |
fi | |
if echo "$PR_BODY" | grep -q '\- \[x\] Run Unit Tests'; then | |
echo "run_utest=true" >> $GITHUB_ENV | |
echo "::set-output name=run_utest::true" | |
else | |
echo "run_utest=false" >> $GITHUB_ENV | |
echo "::set-output name=run_utest::false" | |
fi |