diff --git a/.github/workflows/github-add-label.yaml b/.github/workflows/github-label.yaml similarity index 68% rename from .github/workflows/github-add-label.yaml rename to .github/workflows/github-label.yaml index 24540ae..1225d38 100644 --- a/.github/workflows/github-add-label.yaml +++ b/.github/workflows/github-label.yaml @@ -8,13 +8,17 @@ on: required: true default: 'main' type: string + GITHUB_LABEL_ACTION: + description: 'The action to perform on the label. Valid values are "add" or "remove".' + required: true + type: string GITHUB_ISSUE_NUMBER: - description: 'The issue number to add the label to.' + description: 'The issue number to add/remove the label from.' required: false type: string default: ${{ github.event.pull_request.number || github.event.issue.number }} GITHUB_LABEL_NAME: - description: 'The name of the label to add.' + description: 'The name of the label to add/remove.' required: true type: string @@ -52,14 +56,20 @@ jobs: - name: info run: | $MAKE info - - name: add-label + - name: label env: + GH_LABEL_ACTION: ${{ inputs.GITHUB_LABEL_ACTION }} GH_REPOSITORY: ${{ github.repository }} GH_ISSUE_NUMBER: ${{ inputs.GITHUB_ISSUE_NUMBER }} GH_LABEL_NAME: ${{ inputs.GITHUB_LABEL_NAME }} run: | - $MAKE github-add-label \ + if [[ "${GH_LABEL_ACTION}" != "add" && "${GH_LABEL_ACTION}" != "remove" ]]; then + echo "Invalid label action. Valid values are 'add' or 'remove'." + exit 1 + fi + GH_REPOSITORY_NAME=$(echo "${GH_REPOSITORY}" | awk -F'/' '{print $2}') + $MAKE github-${GH_LABEL_ACTION}-label \ GITHUB_ARGS="-t ${{ steps.token.outputs.token }} \ - -r ${GH_REPOSITORY} \ + -r ${GH_REPOSITORY_NAME} \ -i ${GH_ISSUE_NUMBER} \ -l '${GH_LABEL_NAME}'" diff --git a/.github/workflows/github-remove-label.yaml b/.github/workflows/github-remove-label.yaml deleted file mode 100644 index 584d2de..0000000 --- a/.github/workflows/github-remove-label.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: github-remove-label - -on: - workflow_call: - inputs: - PRIMUS_REF: - description: 'The primus ref to checkout.' - required: true - default: 'main' - type: string - GITHUB_ISSUE_NUMBER: - description: 'The issue number to remove the label from.' - required: false - type: string - default: ${{ github.event.pull_request.number || github.event.issue.number }} - GITHUB_LABEL_NAME: - description: 'The name of the label to remove.' - required: true - type: string - -defaults: - run: - shell: bash - -env: - PRIMUS_HOME: .primus - MAKE: make --no-print-directory --makefile=.primus/src/make/main.mk - -jobs: - signoz: - runs-on: ubuntu-latest - permissions: - contents: 'read' - id-token: 'write' - steps: - - name: self-checkout - uses: actions/checkout@v4 - - id: token - name: github-token-gen - uses: actions/create-github-app-token@v1 - with: - app-id: ${{ secrets.PRIMUS_APP_ID }} - private-key: ${{ secrets.PRIMUS_PRIVATE_KEY }} - owner: ${{ github.repository_owner }} - - name: primus-checkout - uses: actions/checkout@v4 - with: - repository: signoz/primus - ref: ${{ inputs.PRIMUS_REF }} - path: .primus - token: ${{ steps.token.outputs.token }} - - name: info - run: | - $MAKE info - - name: remove-label - env: - GH_REPOSITORY: ${{ github.repository }} - GH_ISSUE_NUMBER: ${{ inputs.GITHUB_ISSUE_NUMBER }} - GH_LABEL_NAME: ${{ inputs.GITHUB_LABEL_NAME }} - run: | - $MAKE github-remove-label \ - GITHUB_ARGS="-t ${{ steps.token.outputs.token }} \ - -r ${GH_REPOSITORY} \ - -i ${GH_ISSUE_NUMBER} \ - -l '${GH_LABEL_NAME}'"