Skip to content

Commit

Permalink
Merge branch 'master' into fix_workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
asofsilva authored Aug 17, 2023
2 parents 581d910 + dfaeafd commit 38635ad
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/scripts/pr-issue-info/apache-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Your pull request **can't** be merged due to missing the **Apache license** statement.

Please add the following statement at the end of the pr description:

`I submit this contribution under the Apache-2.0 license.`

In case the statement has already been added, make sure it is the last sentence in the description and the only one in its line.

Thank you!
*KICS Team*
52 changes: 52 additions & 0 deletions .github/workflows/check-apache-license.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: check-apache-license
on:
pull_request_target:
types: [opened, synchronize, edited, reopened]
branches:
- master
jobs:
check-license:
runs-on: ubuntu-latest
env:
BODY: ${{ github.event.pull_request.body }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
persist-credentials: false
sparse-checkout: |
.github/scripts/pr-issue-info/apache-check.md
- name: Check for Apache License
run: |
echo "$BODY" | grep -iPq "^I submit this contribution under the Apache-2.0 license.$" || echo "CHECK_FAILED=true" >> $GITHUB_ENV
- name: Check for comment tag
if: env.CHECK_FAILED != 'true'
run: |
comments=$(curl -s -H "Authorization: token ${{ secrets.KICS_BOT_PAT }}" \
-X GET "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments")
if echo "$comments" | grep -q "apache_license"; then
echo "TAG_EXISTS=true" >> $GITHUB_ENV
else
echo "TAG_EXISTS=false" >> $GITHUB_ENV
fi
- name: Delete comment if license is fixed
if: env.TAG_EXISTS == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
Deleting comment...
comment_tag: apache_license
mode: delete
GITHUB_TOKEN: ${{ secrets.KICS_BOT_PAT }}
- name: Add comment if no license
if: env.CHECK_FAILED == 'true'
uses: thollander/actions-comment-pull-request@v2
with:
filePath: .github/scripts/pr-issue-info/apache-check.md
comment_tag: apache_license
mode: recreate
create_if_not_exists: true
GITHUB_TOKEN: ${{ secrets.KICS_BOT_PAT }}
- name: Workflow failed
if: env.CHECK_FAILED == 'true'
run: exit 1

0 comments on commit 38635ad

Please sign in to comment.