From d3cc6b805ec5cf0acba67fd4fb7f408a35ddea20 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..d0e94ce2 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) { projectsV2(first: 20) { nodes { title } } } } }", "variables" : "{ \"pr\": '${NUMBER}', \"owner\": \"'${OWNER}'\", \"repo\": \"'${REPO}'\" }" }' https://api.github.com/graphql | grep ""; 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 }}