From 31a238da927720a04188b36b693ede2eacd8e6c6 Mon Sep 17 00:00:00 2001 From: Jaken Herman Date: Mon, 14 Oct 2024 12:29:13 -0500 Subject: [PATCH] Create autopr.yaml Signed-off-by: Jaken Herman --- .github/workflows/autopr.yaml | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/autopr.yaml diff --git a/.github/workflows/autopr.yaml b/.github/workflows/autopr.yaml new file mode 100644 index 0000000..792abcd --- /dev/null +++ b/.github/workflows/autopr.yaml @@ -0,0 +1,45 @@ +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 install jq + - name: Check if label was added by a collaborator + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + is_collaborator=$(curl -s -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github+json" \ + "https://api.github.com/repos/${{ github.repository }}/collaborators/${{ github.event.sender.login }}" | jq -r '.message') + + if [ "$is_collaborator" == "Not Found" ]; then + echo "Label not added by a collaborator. Skipping action." + exit 78 + fi + - name: Checkout + uses: actions/checkout@v2 + with: + ref: main + fetch-depth: 1 + - name: AutoPR + uses: irgolic/AutoPR@main + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + base_branch: main