Skip to content

fix: add check for OPENAI_API_KEY in AutoPR workflow to ensure it is … #4

fix: add check for OPENAI_API_KEY in AutoPR workflow to ensure it is …

fix: add check for OPENAI_API_KEY in AutoPR workflow to ensure it is … #4

Workflow file for this run

on:
push:
branches:
- main
issues:
types: [labeled]
issue_comment:
types: [created]
pull_request_target:
types: [labeled]
permissions:
contents: write
issues: write
pull-requests: write
jobs:
autopr:
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Check if label was added by a collaborator
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Use the collaborators endpoint and check HTTP status code. 204 = collaborator, 404 = not collaborator
status=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}")
if [ "$status" != "204" ]; then
echo "Label not added by a collaborator (HTTP $status). Skipping action."
exit 78
fi
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 1
- name: Ensure OPENAI_API_KEY is set
run: |
if [ -z "${OPENAI_API_KEY}" ]; then
echo "OPENAI_API_KEY is not set in repository secrets. Skipping AutoPR."
exit 78
fi
- name: AutoPR
uses: irgolic/[email protected]
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
base_branch: main