From ff9588ad7a031cb58f564f6938e7afdcd8a9358c Mon Sep 17 00:00:00 2001 From: Staylortt Date: Fri, 1 Nov 2024 20:07:55 -0500 Subject: [PATCH 1/3] Adding workflow for updating the custom field "Last Updated". --- .github/workflows/issue-last-updated.yml | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/issue-last-updated.yml diff --git a/.github/workflows/issue-last-updated.yml b/.github/workflows/issue-last-updated.yml new file mode 100644 index 000000000..bf238d13b --- /dev/null +++ b/.github/workflows/issue-last-updated.yml @@ -0,0 +1,45 @@ +name: Update Project Last Updated Date on Issue Update or comment + +on: + issues: + types: [edited, opened] + issue_comment: + types: [created] + +env: + GITHUB_TOKEN: ${{ secrets.ISSUE_TOKEN }} + +jobs: + update_project_date: + runs-on: ubuntu-latest + steps: + - name: Get Issue ID + id: get_issue_id + run: | + issue_number=${{ github.event.issue.number }} + issue_details=$(curl -H "Authorization: Bearer ${{ secrets.ISSUE_TOKEN }}" -s "https://api.github.com/repos/${{ github.repository }}/issues/$issue_number") + issue_id=$(echo "$issue_details" | jq -r '.node_id') + echo "issue_id=$issue_id" >> $GITHUB_ENV + + - name: Get Item ID for Issue + id: get_item_by_issue_id + run: | + ITEM_ID=$(curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "query": "query($projectId: ID!) { node(id: $projectId) { ... on ProjectV2 { items(first: 100) { nodes { id content { ... on Issue { id } } } } } } }", + "variables": { + "projectId": "'"${{ secrets.TT_FORGE_PROJECT_ID }}"'" + } + }' \ + https://api.github.com/graphql | jq -r '.data.node.items.nodes[] | select(.content.id=="'"${{ env.issue_id }}"'") | .id') + echo "ITEM_ID=$ITEM_ID" >> $GITHUB_ENV + + - name: Update Project Field + run: | + current_date=$(date +%Y-%m-%d) + curl -H "Authorization: Bearer ${{ secrets.ISSUE_TOKEN }}" \ + -H "Content-Type: application/json" \ + -d "{ \"query\": \"mutation { updateProjectV2ItemFieldValue(input: { projectId: \\\"${{ secrets.TT_FORGE_PROJECT_ID }}\\\", itemId: \\\"${{ env.ITEM_ID }}\\\", fieldId: \\\"${{ secrets.TT_FORGE_PROJECT_LAST_UPDATED_ID }}\\\", value: { date: \\\"$current_date\\\" } }) { clientMutationId } }\" }" \ + -X POST \ + "https://api.github.com/graphql" \ No newline at end of file From 04e1e95be4f7b14f9de5b3778e3285dcf92ca6bd Mon Sep 17 00:00:00 2001 From: Staylortt Date: Fri, 1 Nov 2024 20:24:26 -0500 Subject: [PATCH 2/3] adding newline per linter --- .github/workflows/issue-last-updated.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-last-updated.yml b/.github/workflows/issue-last-updated.yml index bf238d13b..557ed9647 100644 --- a/.github/workflows/issue-last-updated.yml +++ b/.github/workflows/issue-last-updated.yml @@ -42,4 +42,4 @@ jobs: -H "Content-Type: application/json" \ -d "{ \"query\": \"mutation { updateProjectV2ItemFieldValue(input: { projectId: \\\"${{ secrets.TT_FORGE_PROJECT_ID }}\\\", itemId: \\\"${{ env.ITEM_ID }}\\\", fieldId: \\\"${{ secrets.TT_FORGE_PROJECT_LAST_UPDATED_ID }}\\\", value: { date: \\\"$current_date\\\" } }) { clientMutationId } }\" }" \ -X POST \ - "https://api.github.com/graphql" \ No newline at end of file + "https://api.github.com/graphql" From 69326201a5c64e4520091a45be966144d7589769 Mon Sep 17 00:00:00 2001 From: Staylortt Date: Sat, 2 Nov 2024 06:52:01 -0500 Subject: [PATCH 3/3] Smore linter changes --- .github/workflows/issue-last-updated.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-last-updated.yml b/.github/workflows/issue-last-updated.yml index 557ed9647..0060b28f8 100644 --- a/.github/workflows/issue-last-updated.yml +++ b/.github/workflows/issue-last-updated.yml @@ -6,7 +6,7 @@ on: issue_comment: types: [created] -env: +env: GITHUB_TOKEN: ${{ secrets.ISSUE_TOKEN }} jobs: