diff --git a/.github/workflows/os-increment-plugin-versions.yml b/.github/workflows/os-increment-plugin-versions.yml index 104a9a03bf..a04297bdbb 100644 --- a/.github/workflows/os-increment-plugin-versions.yml +++ b/.github/workflows/os-increment-plugin-versions.yml @@ -85,36 +85,36 @@ jobs: app_id: ${{ secrets.APP_ID }} private_key: ${{ secrets.APP_PRIVATE_KEY }} installation_id: 22958780 - - name: Check if label exists - id: check_label + - name: Check and Create label + id: check_create_label uses: actions/github-script@v6 with: github-token: ${{ steps.github_app_token.outputs.token }} result-encoding: string script: | - const { data: labels } = await github.rest.issues.listLabelsForRepo({ + const labelName = "v${{ env.OPENSEARCH_VERSION_NUMBER }}"; + let labelFound = false; + const label = await github.rest.issues.getLabel({ owner: context.repo.owner, repo: "${{ matrix.entry.repo }}", - per_page: 100 + name: labelName }); - const labelFound = labels.some(label => label.name === 'v${{ env.OPENSEARCH_VERSION_NUMBER }}'); + if (label) { + labelFound = true; + } else { + const randomColor = Math.floor(Math.random() * 16777215).toString(16); + const newLabel = { + owner: context.repo.owner, + repo: context.repo.repo, + name: labelName, + color: randomColor, + description: labelName + }; + await github.rest.issues.createLabel(newLabel); + labelFound = true; + } console.log(labelFound); return labelFound - - name: Create label - if: ${{ steps.check_label.outputs.result != 'true' }} - uses: actions/github-script@v6 - with: - github-token: ${{ steps.github_app_token.outputs.token }} - script: | - const randomColor = Math.floor(Math.random() * 16777215).toString(16); - const newLabel = { - owner: context.repo.owner, - repo: "${{ matrix.entry.repo }}", - name: "v${{ env.OPENSEARCH_VERSION_NUMBER }}", - color: randomColor, - description: "v${{ env.OPENSEARCH_VERSION_NUMBER }}" - }; - await github.rest.issues.createLabel(newLabel); - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v4 @@ -136,4 +136,4 @@ jobs: - name: Check outputs run: |- echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" \ No newline at end of file diff --git a/.github/workflows/osd-increment-plugin-versions.yml b/.github/workflows/osd-increment-plugin-versions.yml index a29628a80a..f7d3442f04 100644 --- a/.github/workflows/osd-increment-plugin-versions.yml +++ b/.github/workflows/osd-increment-plugin-versions.yml @@ -109,29 +109,29 @@ jobs: github-token: ${{ steps.github_app_token.outputs.token }} result-encoding: string script: | - const { data: labels } = await github.rest.issues.listLabelsForRepo({ + const labelName = "v${{ env.DASHBOARD_VERSION }}"; + let labelFound = false; + const label = await github.rest.issues.getLabel({ owner: context.repo.owner, repo: "${{ matrix.entry.repo }}", - per_page: 100 + name: labelName }); - const labelFound = labels.some(label => label.name === 'v${{ env.DASHBOARD_VERSION }}'); + if (label) { + labelFound = true; + } else { + const randomColor = Math.floor(Math.random() * 16777215).toString(16); + const newLabel = { + owner: context.repo.owner, + repo: context.repo.repo, + name: labelName, + color: randomColor, + description: labelName + }; + await github.rest.issues.createLabel(newLabel); + labelFound = true; + } console.log(labelFound); return labelFound - - name: Create label - if: ${{ steps.check_label.outputs.result != 'true' }} - uses: actions/github-script@v6 - with: - github-token: ${{ steps.github_app_token.outputs.token }} - script: | - const randomColor = Math.floor(Math.random() * 16777215).toString(16); - const newLabel = { - owner: context.repo.owner, - repo: "${{ matrix.entry.repo }}", - name: "v${{ env.DASHBOARD_VERSION }}", - color: randomColor, - description: "v${{ env.DASHBOARD_VERSION }}" - }; - await github.rest.issues.createLabel(newLabel); - name: Create Pull Request id: cpr uses: peter-evans/create-pull-request@v5