From e38e2c830c50bfb04bfaeeaf8385d2a3e7e94e1c Mon Sep 17 00:00:00 2001 From: bvanbreukelen Date: Thu, 20 Jun 2024 17:33:51 +0200 Subject: [PATCH] feat: [#1] Check for nonempty PR description --- .github/dependabot.yml | 7 +++++ .github/workflows/mcvs-pr-validation.yml | 18 +++++++++++++ README.md | 34 +++++++++++++++++++++++- action.yml | 22 +++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/mcvs-pr-validation.yml create mode 100644 action.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..900df32 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +--- +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/mcvs-pr-validation.yml b/.github/workflows/mcvs-pr-validation.yml new file mode 100644 index 0000000..e69bee2 --- /dev/null +++ b/.github/workflows/mcvs-pr-validation.yml @@ -0,0 +1,18 @@ +--- +name: MCVS-PR-validation-action +"on": + pull_request: + types: + - edited + - opened + - reopened + - synchronize + workflow_call: +jobs: + MCVS-PR-validation-action: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.1 + - uses: schubergphilis/mcvs-pr-validation-action@v0.1.0 + env: + GH_TOKEN: ${{ secrets.SETTINGS_GUARD }} diff --git a/README.md b/README.md index aed52e7..757c66c 100644 --- a/README.md +++ b/README.md @@ -1 +1,33 @@ -# mcvs-pr-validation-action \ No newline at end of file +# MCVS-PR-validation-action + +Mission Critical Vulnerability Scanner (MCVS) Pull Request (PR) Validation +Action is a custom [GitHub Action](https://github.com/features/actions) that +consists of the following steps: + +- Nonempty PR description. + +## Usage + +Create a `.github/workflows/mcvs-pr-validation.yml` file with the following +content: + +```bash +--- +name: MCVS-PR-validation-action +'on': + pull_request: + types: + - edited + - opened + - reopened + - synchronize + workflow_call: +jobs: + MCVS-PR-validation-action: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4.1.1 + - uses: schubergphilis/mcvs-pr-validation-action@v0.1.0 + env: + GH_TOKEN: ${{ secrets.SETTINGS_GUARD }} +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..b4773b1 --- /dev/null +++ b/action.yml @@ -0,0 +1,22 @@ +--- +name: mcvs-pr-validation-action +description: | + Mission Critical Vulnerability Scanner (MCVS) Pull Request (PR) Validation + action. +runs: + using: composite + steps: + - name: Check whether PR description is nonempty + run: | + PR_NUMBER="${GITHUB_REF_NAME/\/merge/}" + if [[ ! ${PR_NUMBER} =~ ^[0-9]+$ ]]; then + echo "PR_NUMBER should be a number, got: ${PR_NUMBER}" + exit 1 + fi + + PR_DESCRIPTION=$(gh pr view ${PR_NUMBER} --json body --jq '.body') + if [[ -z "${PR_DESCRIPTION}" ]]; then + echo "Please provide a description for the pull request" + exit 1 + fi + shell: bash