Skip to content

Commit

Permalink
create one pipeline for start and end dates
Browse files Browse the repository at this point in the history
Signed-off-by: Rakshit Gondwal <[email protected]>
  • Loading branch information
rakshitgondwal committed Mar 13, 2023
1 parent 7a0ab03 commit 9e3e8a8
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 89 deletions.
Original file line number Diff line number Diff line change
@@ -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!) {
Expand Down Expand Up @@ -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

Expand All @@ -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 (
Expand All @@ -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
85 changes: 0 additions & 85 deletions .github/workflows/set-end-date.yml

This file was deleted.

0 comments on commit 9e3e8a8

Please sign in to comment.