From f939eec728c8d3b02f474fc2e8de44c53cb1f191 Mon Sep 17 00:00:00 2001 From: caughtquick Date: Tue, 27 Feb 2024 21:17:07 -0800 Subject: [PATCH] Add Autotagging tool --- .github/workflows/auto-tag.yaml | 36 +++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/auto-tag.yaml diff --git a/.github/workflows/auto-tag.yaml b/.github/workflows/auto-tag.yaml new file mode 100644 index 00000000000000..b02d1558cd4c3b --- /dev/null +++ b/.github/workflows/auto-tag.yaml @@ -0,0 +1,36 @@ +name: New Package PR Workflow + +on: + pull_request: + types: [opened, synchronize] + push: + branches: + - main # Adjust the branch name as needed + +jobs: + tag_new_package_pr: + runs-on: ubuntu-latest + + steps: + - name: Check if PR is for a new package + id: check_new_package + run: | + pr_title=$(echo "${{ github.event.pull_request.title }}" | tr '[:upper:]' '[:lower:]') + if [[ $pr_title == *"new package"* ]]; then + echo "new_package=true" >> $GITHUB_ENV + fi + + - name: Tag PR if it's for a new package + if: env.new_package == 'true' + run: | + pr_number=${{ github.event.pull_request.number }} + token=$GITHUB_TOKEN + label_name="new-package" + api_url="https://api.github.com/repos/${{ github.repository }}/issues/${pr_number}/labels" + + curl -X POST \ + -H "Authorization: token $token" \ + -H "Accept: application/vnd.github.v3+json" \ + "$api_url" \ + -d "{\"labels\":[\"$label_name\"]}" +