added a file #14
Workflow file for this run
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: PR License Check | |
on: | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
run-license-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9.12' | |
- name: Install dependencies | |
run: python3 -m pip install requests | |
- name: Run license.py and capture output | |
id: license_check | |
env: | |
PAT_TOKEN: ${{ secrets.GH_PAT }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
run: | | |
output=$(python3 license.py $PR_NUMBER $PAT_TOKEN) | |
echo "$output" > license_result.txt | |
echo "::set-output name=output::$output" | |
- name: Post comment on GitHub | |
run: | | |
COMMENT_BODY=$(cat license_result.txt) | |
# Replace newline characters with '\n' to properly format the JSON payload | |
COMMENT_BODY=$(echo "$COMMENT_BODY" | sed 's/$/\\n/g' | tr -d '\n') | |
echo "Posting comment to PR#${{ github.event.pull_request.number }}:" | |
echo "$COMMENT_BODY" | |
echo "JSON Payload:" | |
echo "{\"body\": \"$COMMENT_BODY\"}" | |
curl -X POST \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token ${{ secrets.GH_PAT }}" \ | |
-H "Content-Type: application/json" \ | |
-d "{\"body\": \"$COMMENT_BODY\"}" \ | |
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" |