From bd15e536f125a676a1c48ad65dc8581f09721043 Mon Sep 17 00:00:00 2001 From: Mark Phelps <209477+markphelps@users.noreply.github.com> Date: Fri, 7 Jun 2024 10:28:35 -0400 Subject: [PATCH] chore: create docs issue for needs docs label (#3153) * chore: create docs issue for needs docs label Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com> * chore: rename workflow; check for existing issues Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com> * chore: rm renamed file Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com> --------- Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .github/workflows/label.yml | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/label.yml diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 0000000000..406eb1b966 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,44 @@ +name: Label PRs + +on: + pull_request: + types: [labeled] + branches: + - main + +jobs: + create-docs-issue: + if: github.event.label.name == 'needs docs' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@v2 + with: + app_id: ${{ secrets.FLIPT_RELEASE_BOT_APP_ID }} + private_key: ${{ secrets.FLIPT_RELEASE_BOT_APP_PEM }} + installation_id: ${{ secrets.FLIPT_RELEASE_BOT_INSTALLATION_ID }} + + - name: Check for existing issues + id: check-issues + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + pr_title=$(jq -r .pull_request.title < $GITHUB_EVENT_PATH) + issue_title="Document: $pr_title" + existing_issue=$(gh issue list --repo ${{ github.repository_owner }}/docs --search "$issue_title" --json title --jq '.[0].title') + echo "::set-output name=issue_exists::$existing_issue" + + - name: Create documentation issue + if: steps.check-issues.outputs.issue_exists == '' + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + pr_title=$(jq -r .pull_request.title < $GITHUB_EVENT_PATH) + pr_url=$(jq -r .pull_request.html_url < $GITHUB_EVENT_PATH) + issue_title="Document: $pr_title" + issue_body="This issue was created to document the following pull request: $pr_url" + gh issue create --title "$issue_title" --body "$issue_body" --repo ${{ github.repository_owner }}/docs