From 9b82826408d19c7f7ebce84eb7873d926a749902 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Thu, 9 Mar 2023 21:48:25 +0530 Subject: [PATCH 1/4] add new pipeline to set start date Signed-off-by: Rakshit Gondwal --- .../{set-date.yml => set-end-date.yml} | 0 .github/workflows/set-start-date.yml | 84 +++++++++++++++++++ 2 files changed, 84 insertions(+) rename .github/workflows/{set-date.yml => set-end-date.yml} (100%) create mode 100644 .github/workflows/set-start-date.yml diff --git a/.github/workflows/set-date.yml b/.github/workflows/set-end-date.yml similarity index 100% rename from .github/workflows/set-date.yml rename to .github/workflows/set-end-date.yml diff --git a/.github/workflows/set-start-date.yml b/.github/workflows/set-start-date.yml new file mode 100644 index 0000000000..0b13524b8c --- /dev/null +++ b/.github/workflows/set-start-date.yml @@ -0,0 +1,84 @@ +name: Set the End Date in the project + +on: + issues: + types: [assigned] +jobs: + set_date: + runs-on: ubuntu-22.04 + steps: + - name: Get project data + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + ORGANIZATION: keptn + PROJECT_NUMBER: 18 + run: | + gh api graphql -f query=' + query($org: String!, $number: Int!) { + organization(login: $org){ + projectV2(number: $number) { + id + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV + echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start Date") | .id' project_data.json) >> $GITHUB_ENV + + - name: Get date + run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV + + - name: Add item id + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + ISSUE_ID: ${{ github.event.issue.node_id }} + run: | + item_id="$( gh api graphql -f query=' + mutation($project:ID!, $issue:ID!) { + addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) { + item { + id + } + } + }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')" + echo 'ITEM_ID='$item_id >> $GITHUB_ENV + + - name: Set Start Date + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + run: | + gh api graphql -f query=' + mutation ( + $project: ID! + $item: ID! + $date_field: ID! + $date_value: Date! + ) { + set_end_date: updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $date_field + value: { + date: $date_value + } + }) { + projectV2Item { + id + } + } + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE From d86ce9b7eb9c9b34a207ac06eb9e5dddbc27058c Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Thu, 9 Mar 2023 21:53:40 +0530 Subject: [PATCH 2/4] modify set-start-date.yml Signed-off-by: Rakshit Gondwal --- .github/workflows/set-start-date.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/set-start-date.yml b/.github/workflows/set-start-date.yml index 0b13524b8c..63cd419538 100644 --- a/.github/workflows/set-start-date.yml +++ b/.github/workflows/set-start-date.yml @@ -1,4 +1,4 @@ -name: Set the End Date in the project +name: Set the Start Date in the project on: issues: @@ -69,7 +69,7 @@ jobs: $date_field: ID! $date_value: Date! ) { - set_end_date: updateProjectV2ItemFieldValue(input: { + set_start_date: updateProjectV2ItemFieldValue(input: { projectId: $project itemId: $item fieldId: $date_field From 9e3e8a8b58ad7f0bd0d117ee2d231666c6e7d7f1 Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Mon, 13 Mar 2023 20:42:06 +0530 Subject: [PATCH 3/4] create one pipeline for start and end dates Signed-off-by: Rakshit Gondwal --- .../{set-start-date.yml => set-date.yml} | 71 +++++++++++++++- .github/workflows/set-end-date.yml | 85 ------------------- 2 files changed, 67 insertions(+), 89 deletions(-) rename .github/workflows/{set-start-date.yml => set-date.yml} (53%) delete mode 100644 .github/workflows/set-end-date.yml diff --git a/.github/workflows/set-start-date.yml b/.github/workflows/set-date.yml similarity index 53% rename from .github/workflows/set-start-date.yml rename to .github/workflows/set-date.yml index 63cd419538..9c7c6ecb86 100644 --- a/.github/workflows/set-start-date.yml +++ b/.github/workflows/set-date.yml @@ -1,17 +1,18 @@ -name: Set the Start Date in the project +name: Set the Date in the project on: issues: - types: [assigned] + types: [assigned, closed] jobs: set_date: runs-on: ubuntu-22.04 steps: - - name: Get project data + - name: Get project data for start date env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} ORGANIZATION: keptn PROJECT_NUMBER: 18 + if: ${{ github.event.action == 'assigned' }} run: | gh api graphql -f query=' query($org: String!, $number: Int!) { @@ -39,7 +40,41 @@ jobs: }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start Date") | .id' project_data.json) >> $GITHUB_ENV - + + - name: Get project data for end date + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + ORGANIZATION: keptn + PROJECT_NUMBER: 18 + if: ${{ github.event.action == 'closed' }} + run: | + gh api graphql -f query=' + query($org: String!, $number: Int!) { + organization(login: $org){ + projectV2(number: $number) { + id + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + options { + id + name + } + } + } + } + } + } + }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json + echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV + echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV + - name: Get date run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV @@ -61,6 +96,7 @@ jobs: - name: Set Start Date env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + if: ${{ github.event.action == 'assigned' }} run: | gh api graphql -f query=' mutation ( @@ -82,3 +118,30 @@ jobs: } } }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE + + - name: Set End Date + env: + GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} + if: ${{ github.event.action == 'closed' }} + run: | + gh api graphql -f query=' + mutation ( + $project: ID! + $item: ID! + $date_field: ID! + $date_value: Date! + ) { + set_end_date: updateProjectV2ItemFieldValue(input: { + projectId: $project + itemId: $item + fieldId: $date_field + value: { + date: $date_value + } + }) { + projectV2Item { + id + } + } + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE + diff --git a/.github/workflows/set-end-date.yml b/.github/workflows/set-end-date.yml deleted file mode 100644 index 39e690f32c..0000000000 --- a/.github/workflows/set-end-date.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Set the End Date in the project - -on: - issues: - types: [closed] -jobs: - set_date: - runs-on: ubuntu-22.04 - steps: - - name: Get project data - env: - GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - ORGANIZATION: keptn - PROJECT_NUMBER: 18 - run: | - gh api graphql -f query=' - query($org: String!, $number: Int!) { - organization(login: $org){ - projectV2(number: $number) { - id - fields(first:20) { - nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json - echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV - echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV - - - name: Get date - run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV - - - name: Add item id - env: - GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - ISSUE_ID: ${{ github.event.issue.node_id }} - run: | - item_id="$( gh api graphql -f query=' - mutation($project:ID!, $issue:ID!) { - addProjectV2ItemById(input: {projectId: $project, contentId: $issue}) { - item { - id - } - } - }' -f project=$PROJECT_ID -f issue=$ISSUE_ID --jq '.data.addProjectV2ItemById.item.id')" - echo 'ITEM_ID='$item_id >> $GITHUB_ENV - - - name: Set End Date - env: - GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - run: | - gh api graphql -f query=' - mutation ( - $project: ID! - $item: ID! - $date_field: ID! - $date_value: Date! - ) { - set_end_date: updateProjectV2ItemFieldValue(input: { - projectId: $project - itemId: $item - fieldId: $date_field - value: { - date: $date_value - } - }) { - projectV2Item { - id - } - } - }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE - From bc3cab36fcc1b2b6d3cc0aea64219bcd84470f7b Mon Sep 17 00:00:00 2001 From: Rakshit Gondwal Date: Tue, 14 Mar 2023 22:44:59 +0530 Subject: [PATCH 4/4] merge two project data steps into one Signed-off-by: Rakshit Gondwal --- .github/workflows/set-date.yml | 48 +++++----------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/.github/workflows/set-date.yml b/.github/workflows/set-date.yml index 9c7c6ecb86..647105ac26 100644 --- a/.github/workflows/set-date.yml +++ b/.github/workflows/set-date.yml @@ -7,12 +7,11 @@ jobs: set_date: runs-on: ubuntu-22.04 steps: - - name: Get project data for start date + - name: Get project data env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} ORGANIZATION: keptn PROJECT_NUMBER: 18 - if: ${{ github.event.action == 'assigned' }} run: | gh api graphql -f query=' query($org: String!, $number: Int!) { @@ -39,41 +38,8 @@ jobs: } }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV - echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start Date") | .id' project_data.json) >> $GITHUB_ENV - - - name: Get project data for end date - env: - GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - ORGANIZATION: keptn - PROJECT_NUMBER: 18 - if: ${{ github.event.action == 'closed' }} - run: | - gh api graphql -f query=' - query($org: String!, $number: Int!) { - organization(login: $org){ - projectV2(number: $number) { - id - fields(first:20) { - nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - options { - id - name - } - } - } - } - } - } - }' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json - echo 'PROJECT_ID='$(jq '.data.organization.projectV2.id' project_data.json) >> $GITHUB_ENV - echo 'DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV + echo 'START_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "Start Date") | .id' project_data.json) >> $GITHUB_ENV + echo 'END_DATE_FIELD_ID='$(jq '.data.organization.projectV2.fields.nodes[] | select(.name== "End Date") | .id' project_data.json) >> $GITHUB_ENV - name: Get date run: echo "DATE=$(date +"%Y-%m-%d")" >> $GITHUB_ENV @@ -96,7 +62,7 @@ jobs: - name: Set Start Date env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - if: ${{ github.event.action == 'assigned' }} + if: github.event.action == 'assigned' run: | gh api graphql -f query=' mutation ( @@ -117,12 +83,12 @@ jobs: id } } - }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$START_DATE_FIELD_ID -f date_value=$DATE - name: Set End Date env: GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_PROJECT_TOKEN }} - if: ${{ github.event.action == 'closed' }} + if: github.event.action == 'closed' run: | gh api graphql -f query=' mutation ( @@ -143,5 +109,5 @@ jobs: id } } - }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$DATE_FIELD_ID -f date_value=$DATE + }' -f project=$PROJECT_ID -f item=$ITEM_ID -f date_field=$END_DATE_FIELD_ID -f date_value=$DATE