Skip to content

updated readme.md

updated readme.md #17

Workflow file for this run

on:
pull_request_target:
types: [opened, reopened, synchronize]
permissions:
contents: read # needed for checkout
pull-requests: write # needed for posting comments
jobs:
post-questionnaire:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout base repo (safe; do NOT checkout PR head here)
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
fetch-depth: 0
- name: Authenticate gh CLI with GITHUB_TOKEN
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Check if questionnaire already answered
id: check
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
# Collect PR comments (robust to empty output)
RESPONSES=$(gh pr view "$PR_NUMBER" --json comments --jq '.comments[].body' 2>/dev/null | grep -i "Ethics & Regulatory Questionnaire" -A 20 || true)
if [[ -z "$RESPONSES" ]]; then
echo "status=missing" >> $GITHUB_OUTPUT
else
echo "status=answered" >> $GITHUB_OUTPUT
fi
- name: Post questionnaire if missing
if: steps.check.outputs.status == 'missing'
run: |
# ensure file exists in the base repo checkout (case-sensitive)
if [[ ! -f .github/ETHICS_QUESTIONNAIRE.MD ]]; then
echo ".github/ETHICS_QUESTIONNAIRE.MD not found in base repo; aborting." >&2
exit 1
fi
gh pr comment ${{ github.event.pull_request.number }} --body-file .github/ETHICS_QUESTIONNAIRE.MD
echo "Posted ethics questionnaire to PR #${{ github.event.pull_request.number }}."