From 3a5bc6f029931b48364025051c1d07dcf8da4b43 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 14 Dec 2023 09:43:23 -0500 Subject: [PATCH] WIP --- .github/workflows/issues-workflow.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/issues-workflow.yaml b/.github/workflows/issues-workflow.yaml index 3017271d..197b200b 100644 --- a/.github/workflows/issues-workflow.yaml +++ b/.github/workflows/issues-workflow.yaml @@ -12,8 +12,23 @@ jobs: add-to-project: name: Add issue to project runs-on: ubuntu-latest + env: + BOARD_NAME: "Kuadrant" + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + NUMBER: ${{ github.event.number }} steps: + - name: Check if issue is already in Project Kuadrant + run: | + if curl -i -H 'Content-Type: application/json' -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -X POST -d '{"query": "query ($pr: Int!, $owner: String!, $repo: String!) { repository(owner: $owner, name: $repo) { pullRequest(number: $pr) { projectItems(first: 20) { nodes { project { title } } } } } }", "variables" : "{ \"pr\": '${PR}', \"owner\": \"'${OWNER}'\", \"repo\": \"'${REPO}'\" }" }' https://api.github.com/graphql | grep "\b$BOARD_NAME\b"; then + echo "Issue is already in Project '$BOARD_NAME', cancelling this workflow"; + echo "ALREADY_IN_BOARD=true" >> $GITHUB_ENV + else + echo "Issue is not in project '$BOARD_NAME', adding it to $BOARD_NAME, if this step fails please have it added by someone from the Kuadrant org and rerun - ignore this failure until then." + echo "ALREADY_IN_BOARD=false" >> $GITHUB_ENV + fi - uses: actions/add-to-project@v0.5.0 + if: ${{ env.ALREADY_IN_BOARD == 'false' }} with: project-url: https://github.com/orgs/Kuadrant/projects/18 github-token: ${{ secrets.ADD_ISSUES_TOKEN }}