From 7e57cf7d4eb984501f9ea6425fc8641f74262740 Mon Sep 17 00:00:00 2001 From: Torben Hansen <50673096+torben-hansen@users.noreply.github.com> Date: Tue, 1 Oct 2024 08:10:41 -0700 Subject: [PATCH] Github action asserting license statement in PR description --- .../workflows/assert_license_statement.yml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/assert_license_statement.yml diff --git a/.github/workflows/assert_license_statement.yml b/.github/workflows/assert_license_statement.yml new file mode 100644 index 0000000000..76ccbb531e --- /dev/null +++ b/.github/workflows/assert_license_statement.yml @@ -0,0 +1,36 @@ +name: Assert PR description license statement +on: + pull_request: + types: [opened, edited] +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true +jobs: + check-pr-description: + if: github.repository_owner == 'aws' + runs-on: ubuntu-latest + + steps: + - name: Install jq + run: | + sudo apt-get update -o Acquire::Languages=none -o Acquire::Translation=none + sudo apt-get install -y jq + + - name: Check PR description + run: | + # Fetches the PR description. + PR_DESCRIPTION=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} | jq -r .body) + + LICENSE_STATEMENT="By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license." + + echo "PR description: ${PR_DESCRIPTION}" + echo "Must contain: ${LICENSE_STATEMENT}" + + # Assert this is the case. + if echo "${PR_DESCRIPTION}" | grep -q "${LICENSE_STATEMENT}"; then + echo "PR description contains license statement." + else + echo "Error: PR description does not contain the required license statement." + exit 1 + fi