From b41d9c7d9d542335f6d3aef1af97ff37bad3fe27 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Thu, 24 Apr 2025 10:28:37 +0200 Subject: [PATCH 01/41] Update roadmap workflow --- .../update-roadmap-project-dates.yml | 191 ++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 .github/workflows/update-roadmap-project-dates.yml diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml new file mode 100644 index 0000000000..de857356b6 --- /dev/null +++ b/.github/workflows/update-roadmap-project-dates.yml @@ -0,0 +1,191 @@ +name: Update Roadmap Dates + +on: + pull_request: + types: [labeled] + +jobs: + update-roadmap-dates: + runs-on: ubuntu-latest + if: | + github.event.label.name == 'awaiting_tech_review' || + github.event.label.name == 'publish' + + permissions: + contents: read + pull-requests: read + repository-projects: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install Octokit + run: npm install @octokit/rest + + - name: Debug Token + run: echo "Token is set" + env: + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} + + - name: Update Project Board Dates + uses: actions/github-script@v6 + with: + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} + script: | + const { Octokit } = require('@octokit/rest'); + const octokit = new Octokit({ auth:process.env.PROJECT_TOKEN }); + + const projectNumber = 4; // Your project number + const orgName = 'ArmDeveloperEcosystem'; + const prNumber = context.payload.pull_request.number; + const labelName = context.payload.label.name; + + async function getProjectItemForPR() { + // Get the project ID + const projectQuery = ` + query { + organization(login:"${orgName}") { + projectV2(number:${projectNumber}) { + id + } + } + } + `; + + const projectResponse = await octokit.graphql(projectQuery); + const projectId = projectResponse.organization.projectV2.id; + + // Find the PR in the project + const prQuery = ` + query { + organization(login:"${orgName}") { + projectV2(number:${projectNumber}) { + items(first:100) { + nodes { + id + content { + ... on PullRequest { + number + repository { + name + } + } + } + } + } + } + } + } + `; + + const prResponse = await octokit.graphql(prQuery); + const items = prResponse.organization.projectV2.items.nodes; + + // Find the item that corresponds to this PR + const item = items.find(item => + item.content && + item.content.number === prNumber && + item.content.repository.name === context.repo.repo + ); + + return { projectId, itemId:item ? item.id:null }; + } + + async function getFieldId(projectId, fieldName) { + const fieldsQuery = ` + query { + node(id:"${projectId}") { + ... on ProjectV2 { + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2IterationField { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + } + ... on ProjectV2DateField { + id + name + } + } + } + } + } + } + `; + + const fieldsResponse = await octokit.graphql(fieldsQuery); + const fields = fieldsResponse.node.fields.nodes; + const field = fields.find(f => f.name === fieldName); + + return field ? field.id :null; + } + + async function updateDateField(projectId, itemId, fieldId, date) { + const mutation = ` + mutation { + updateProjectV2ItemFieldValue( + input:{ + projectId:"${projectId}" + itemId:"${itemId}" + fieldId:"${fieldId}" + value:{ + date:"${date}" + } + } + ) { + projectV2Item { + id + } + } + } + `; + + return await octokit.graphql(mutation); + } + + async function main() { + try { + const { projectId, itemId } = await getProjectItemForPR(); + if (!itemId) { + console.log('PR not found in project board'); + return; + } + + const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format + + if (labelName === 'awaiting_tech_review') { + const startDateFieldId = await getFieldId(projectId, 'Start Date'); + if (startDateFieldId) { + await updateDateField(projectId, itemId, startDateFieldId, today); + console.log('Updated Start Date to', today); + } else { + console.log('Start Date field not found'); + } + } else if (labelName === 'publish') { + const publishDateFieldId = await getFieldId(projectId, 'Publish Date'); + if (publishDateFieldId) { + await updateDateField(projectId, itemId, publishDateFieldId, today); + console.log('Updated Publish Date to', today); + } else { + console.log('Publish Date field not found'); + } + } + } catch (error) { + console.error('Error updating project board:', error); + core.setFailed(`Error updating project board:${error.message}`); + } + } From 9ef5ba2fa268eae4714e0bd4b2150e9ef3f601a0 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Thu, 24 Apr 2025 10:41:33 +0200 Subject: [PATCH 02/41] Update roadmap workflow --- .github/workflows/update-roadmap-project-dates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml index de857356b6..42ff65beef 100644 --- a/.github/workflows/update-roadmap-project-dates.yml +++ b/.github/workflows/update-roadmap-project-dates.yml @@ -36,10 +36,10 @@ jobs: - name: Update Project Board Dates uses: actions/github-script@v6 with: - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} + github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit({ auth:process.env.PROJECT_TOKEN }); + const octokit = new Octokit({ auth: github.token }); const projectNumber = 4; // Your project number const orgName = 'ArmDeveloperEcosystem'; From a1929fe126c3377e1b8709127cbbc39c2fa1aace Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Thu, 24 Apr 2025 10:53:05 +0200 Subject: [PATCH 03/41] Test dispatched solution --- .github/workflows/dispatch-roadmap-update.yml | 26 +++ .github/workflows/roadmap-update.yml | 176 ++++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 .github/workflows/dispatch-roadmap-update.yml create mode 100644 .github/workflows/roadmap-update.yml diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml new file mode 100644 index 0000000000..b86284ec57 --- /dev/null +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -0,0 +1,26 @@ +name: Dispatch Roadmap Update + +on: + pull_request: + types: [labeled] + +jobs: + call-privileged-update: + if: | + github.event.label.name == 'awaiting_tech_review' || + github.event.label.name == 'publish' + runs-on: ubuntu-latest + + steps: + - name: Trigger privileged workflow via repository_dispatch + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.PROJECT_TOKEN }} + repository: ArmDeveloperEcosystem/arm-learning-paths + event-type: update-project-dates + client-payload: >- + { + "pr_number": ${{ github.event.pull_request.number }}, + "label": "${{ github.event.label.name }}", + "repo": "${{ github.repository }}" + } \ No newline at end of file diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml new file mode 100644 index 0000000000..b1c42e590c --- /dev/null +++ b/.github/workflows/roadmap-update.yml @@ -0,0 +1,176 @@ +name: Privileged Update Roadmap Dates + +on: + repository_dispatch: + types: [update-project-dates] + +jobs: + update-project: + runs-on: ubuntu-latest + + steps: + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Install Octokit + run: npm install @octokit/rest + + - name: Update Project Board Dates + uses: actions/github-script@v6 + with: + script: | + const { Octokit } = require('@octokit/rest'); + const octokit = new Octokit({ auth: github.token }); + + const projectNumber = 4; // Your project number + const orgName = 'ArmDeveloperEcosystem'; + const prNumber = context.payload.pull_request.number; + const labelName = context.payload.label.name; + + async function getProjectItemForPR() { + // Get the project ID + const projectQuery = ` + query { + organization(login:"${orgName}") { + projectV2(number:${projectNumber}) { + id + } + } + } + `; + + const projectResponse = await octokit.graphql(projectQuery); + const projectId = projectResponse.organization.projectV2.id; + + // Find the PR in the project + const prQuery = ` + query { + organization(login:"${orgName}") { + projectV2(number:${projectNumber}) { + items(first:100) { + nodes { + id + content { + ... on PullRequest { + number + repository { + name + } + } + } + } + } + } + } + } + `; + + const prResponse = await octokit.graphql(prQuery); + const items = prResponse.organization.projectV2.items.nodes; + + // Find the item that corresponds to this PR + const item = items.find(item => + item.content && + item.content.number === prNumber && + item.content.repository.name === context.repo.repo + ); + + return { projectId, itemId:item ? item.id:null }; + } + + async function getFieldId(projectId, fieldName) { + const fieldsQuery = ` + query { + node(id:"${projectId}") { + ... on ProjectV2 { + fields(first:20) { + nodes { + ... on ProjectV2Field { + id + name + } + ... on ProjectV2IterationField { + id + name + } + ... on ProjectV2SingleSelectField { + id + name + } + ... on ProjectV2DateField { + id + name + } + } + } + } + } + } + `; + + const fieldsResponse = await octokit.graphql(fieldsQuery); + const fields = fieldsResponse.node.fields.nodes; + const field = fields.find(f => f.name === fieldName); + + return field ? field.id :null; + } + + async function updateDateField(projectId, itemId, fieldId, date) { + const mutation = ` + mutation { + updateProjectV2ItemFieldValue( + input:{ + projectId:"${projectId}" + itemId:"${itemId}" + fieldId:"${fieldId}" + value:{ + date:"${date}" + } + } + ) { + projectV2Item { + id + } + } + } + `; + + return await octokit.graphql(mutation); + } + + async function main() { + try { + const { projectId, itemId } = await getProjectItemForPR(); + if (!itemId) { + console.log('PR not found in project board'); + return; + } + + const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format + + if (labelName === 'awaiting_tech_review') { + const startDateFieldId = await getFieldId(projectId, 'Start Date'); + if (startDateFieldId) { + await updateDateField(projectId, itemId, startDateFieldId, today); + console.log('Updated Start Date to', today); + } else { + console.log('Start Date field not found'); + } + } else if (labelName === 'publish') { + const publishDateFieldId = await getFieldId(projectId, 'Publish Date'); + if (publishDateFieldId) { + await updateDateField(projectId, itemId, publishDateFieldId, today); + console.log('Updated Publish Date to', today); + } else { + console.log('Publish Date field not found'); + } + } + } catch (error) { + console.error('Error updating project board:', error); + core.setFailed(`Error updating project board:${error.message}`); + } + } + env: + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} \ No newline at end of file From 4f66f413aa4334d4a49860b54a541cdc59efe5ef Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Thu, 24 Apr 2025 11:01:56 +0200 Subject: [PATCH 04/41] Use pull_request_target event --- .github/workflows/dispatch-roadmap-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index b86284ec57..6ac5f994fa 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,7 +1,7 @@ name: Dispatch Roadmap Update on: - pull_request: + pull_request_target: types: [labeled] jobs: From 84577b4326db0560be50a646d2e65d1b2d1ba63a Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 14:40:59 +0200 Subject: [PATCH 05/41] Change token --- .github/workflows/dispatch-roadmap-update.yml | 2 +- .github/workflows/roadmap-update.yml | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 6ac5f994fa..b86284ec57 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,7 +1,7 @@ name: Dispatch Roadmap Update on: - pull_request_target: + pull_request: types: [labeled] jobs: diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index b1c42e590c..d73ba1e6fc 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -20,6 +20,7 @@ jobs: - name: Update Project Board Dates uses: actions/github-script@v6 with: + github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); const octokit = new Octokit({ auth: github.token }); @@ -171,6 +172,4 @@ jobs: console.error('Error updating project board:', error); core.setFailed(`Error updating project board:${error.message}`); } - } - env: - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} \ No newline at end of file + } \ No newline at end of file From 2ed338c87165e377cdb32aea08dc48f7170a990d Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 15:11:35 +0200 Subject: [PATCH 06/41] Restore current workflow --- .github/workflows/update-roadmap-project-dates.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml index 42ff65beef..1004943748 100644 --- a/.github/workflows/update-roadmap-project-dates.yml +++ b/.github/workflows/update-roadmap-project-dates.yml @@ -36,10 +36,10 @@ jobs: - name: Update Project Board Dates uses: actions/github-script@v6 with: - github-token: ${{ secrets.PROJECT_TOKEN }} + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit({ auth: github.token }); + const octokit = new Octokit({ auth:process.env.GITHUB_TOKEN }); const projectNumber = 4; // Your project number const orgName = 'ArmDeveloperEcosystem'; From 93ed964502fc5a44fdc972762a0d0262d6d37887 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 15:16:52 +0200 Subject: [PATCH 07/41] Add debug step for dispatch --- .github/workflows/dispatch-roadmap-update.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index b86284ec57..c363eeff4a 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,7 +1,7 @@ name: Dispatch Roadmap Update on: - pull_request: + pull_request_target: types: [labeled] jobs: @@ -12,6 +12,14 @@ jobs: runs-on: ubuntu-latest steps: + - name: Debug secret + run: | + if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then + echo "❌ PROJECT_TOKEN is not set" + exit 1 + else + echo "✅ PROJECT_TOKEN is present" + fi - name: Trigger privileged workflow via repository_dispatch uses: peter-evans/repository-dispatch@v3 with: From 2c17c1221e3501d0887d5a91e7842097ebe981cb Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 16:16:19 +0200 Subject: [PATCH 08/41] Test comment approach --- .github/workflows/dispatch-roadmap-update.yml | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index c363eeff4a..12bf4d490d 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,26 +1,32 @@ name: Dispatch Roadmap Update on: - pull_request_target: + pull_request: types: [labeled] + issue_comment: + types: [created] jobs: - call-privileged-update: - if: | - github.event.label.name == 'awaiting_tech_review' || - github.event.label.name == 'publish' + handle-label: + if: github.event_name == 'pull_request' && github.event.label.name == 'awaiting_tech_review' runs-on: ubuntu-latest + steps: + - name: Comment on PR to trigger privileged job + uses: peter-evans/create-or-update-comment@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + @project-bot dispatch update-project-dates label=awaiting_tech_review + handle-comment-dispatch: + if: | + github.event_name == 'issue_comment' && + github.event.issue.pull_request && + startsWith(github.event.comment.body, '@project-bot dispatch update-project-dates') + runs-on: ubuntu-latest steps: - - name: Debug secret - run: | - if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then - echo "❌ PROJECT_TOKEN is not set" - exit 1 - else - echo "✅ PROJECT_TOKEN is present" - fi - - name: Trigger privileged workflow via repository_dispatch + - name: Dispatch update-project-dates uses: peter-evans/repository-dispatch@v3 with: token: ${{ secrets.PROJECT_TOKEN }} From 22da50e7e2cd50f7344d5822393829f59494f277 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 16:28:45 +0200 Subject: [PATCH 09/41] Revert comment approach --- .github/workflows/dispatch-roadmap-update.yml | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 12bf4d490d..d4faa7a509 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -3,30 +3,24 @@ name: Dispatch Roadmap Update on: pull_request: types: [labeled] - issue_comment: - types: [created] jobs: - handle-label: - if: github.event_name == 'pull_request' && github.event.label.name == 'awaiting_tech_review' - runs-on: ubuntu-latest - steps: - - name: Comment on PR to trigger privileged job - uses: peter-evans/create-or-update-comment@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - issue-number: ${{ github.event.pull_request.number }} - body: | - @project-bot dispatch update-project-dates label=awaiting_tech_review - - handle-comment-dispatch: + call-privileged-update: if: | - github.event_name == 'issue_comment' && - github.event.issue.pull_request && - startsWith(github.event.comment.body, '@project-bot dispatch update-project-dates') + github.event.label.name == 'awaiting_tech_review' || + github.event.label.name == 'publish' runs-on: ubuntu-latest + steps: - - name: Dispatch update-project-dates + - name: Debug secret + run: | + if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then + echo "❌ PROJECT_TOKEN is not set" + exit 1 + else + echo "✅ PROJECT_TOKEN is present" + fi + - name: Trigger privileged workflow via repository_dispatch uses: peter-evans/repository-dispatch@v3 with: token: ${{ secrets.PROJECT_TOKEN }} From 0c1a8a1011d6c6c1a086a05cbe3f541b0f2da156 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 16:33:07 +0200 Subject: [PATCH 10/41] Change trigger type --- .github/workflows/dispatch-roadmap-update.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index d4faa7a509..d169fc803b 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,8 +1,8 @@ name: Dispatch Roadmap Update on: - pull_request: - types: [labeled] + pull_request_target: + types: [synchronize, labeled] jobs: call-privileged-update: From fc52d04caab85d5095532f98f5487b914df1ef81 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 17:11:05 +0200 Subject: [PATCH 11/41] Update types list --- .github/workflows/dispatch-roadmap-update.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index d169fc803b..10d8c000a2 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -2,7 +2,8 @@ name: Dispatch Roadmap Update on: pull_request_target: - types: [synchronize, labeled] + types: + - labeled jobs: call-privileged-update: From 1b7a9fb5941382edafde4142a0af76c82b39175c Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 17:26:28 +0200 Subject: [PATCH 12/41] Use webhook approach --- .github/workflows/dispatch-roadmap-update.yml | 27 +++++-------------- .github/workflows/roadmap-update.yml | 6 +++-- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 10d8c000a2..6479886820 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,7 +1,7 @@ name: Dispatch Roadmap Update on: - pull_request_target: + pull_request: types: - labeled @@ -13,23 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: Debug secret + - name: Trigger Roadmap Update workflow run: | - if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then - echo "❌ PROJECT_TOKEN is not set" - exit 1 - else - echo "✅ PROJECT_TOKEN is present" - fi - - name: Trigger privileged workflow via repository_dispatch - uses: peter-evans/repository-dispatch@v3 - with: - token: ${{ secrets.PROJECT_TOKEN }} - repository: ArmDeveloperEcosystem/arm-learning-paths - event-type: update-project-dates - client-payload: >- - { - "pr_number": ${{ github.event.pull_request.number }}, - "label": "${{ github.event.label.name }}", - "repo": "${{ github.repository }}" - } \ No newline at end of file + curl -X POST \ + -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/${{ github.repository }}/actions/workflows/roadmap-update.yml/dispatches \ + -d '{"ref": "${{ github.base_ref }}"}' \ No newline at end of file diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index d73ba1e6fc..09ac5332fa 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -1,8 +1,10 @@ name: Privileged Update Roadmap Dates on: - repository_dispatch: - types: [update-project-dates] + workflow_run: + workflows: ["Dispatch Roadmap Update"] + types: + - completed jobs: update-project: From c39e68da2542998c72e32af8618561318ebc7c2e Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 17:38:20 +0200 Subject: [PATCH 13/41] Trigger existing workflow --- .github/workflows/dispatch-roadmap-update.yml | 5 +++-- .github/workflows/update-roadmap-project-dates.yml | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 6479886820..37d9f00c1c 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -15,8 +15,9 @@ jobs: steps: - name: Trigger Roadmap Update workflow run: | - curl -X POST \ + curl -L \ + -X POST \ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/actions/workflows/roadmap-update.yml/dispatches \ + https://api.github.com/repos/${{ github.repository }}/actions/workflows/update-roadmap-project-dates.yml/dispatches \ -d '{"ref": "${{ github.base_ref }}"}' \ No newline at end of file diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml index 1004943748..9d7debe38d 100644 --- a/.github/workflows/update-roadmap-project-dates.yml +++ b/.github/workflows/update-roadmap-project-dates.yml @@ -1,8 +1,10 @@ name: Update Roadmap Dates on: - pull_request: - types: [labeled] + workflow_run: + workflows: ["Dispatch Roadmap Update"] + types: + - completed jobs: update-roadmap-dates: From fd17948d1ddf4ad355c730e62d9a050e744c91fb Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 18:14:42 +0200 Subject: [PATCH 14/41] Update call --- .github/workflows/dispatch-roadmap-update.yml | 8 +------- .github/workflows/update-roadmap-project-dates.yml | 4 +++- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 37d9f00c1c..29f4777fa0 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -14,10 +14,4 @@ jobs: steps: - name: Trigger Roadmap Update workflow - run: | - curl -L \ - -X POST \ - -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/actions/workflows/update-roadmap-project-dates.yml/dispatches \ - -d '{"ref": "${{ github.base_ref }}"}' \ No newline at end of file + run: echo "Hello World" \ No newline at end of file diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml index 9d7debe38d..ebdf49948e 100644 --- a/.github/workflows/update-roadmap-project-dates.yml +++ b/.github/workflows/update-roadmap-project-dates.yml @@ -2,10 +2,12 @@ name: Update Roadmap Dates on: workflow_run: - workflows: ["Dispatch Roadmap Update"] + workflows: + - Dispatch Roadmap Update types: - completed + jobs: update-roadmap-dates: runs-on: ubuntu-latest From 3ee84b2310a13b28d9924c63eb149e8d6b8efa50 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Mon, 5 May 2025 18:18:10 +0200 Subject: [PATCH 15/41] Add workflows for testing --- .github/workflows/dispatch-roadmap-update.yml | 4 +- .../update-roadmap-project-dates.yml | 195 ------------------ 2 files changed, 1 insertion(+), 198 deletions(-) delete mode 100644 .github/workflows/update-roadmap-project-dates.yml diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 29f4777fa0..d7c5aba130 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -7,9 +7,7 @@ on: jobs: call-privileged-update: - if: | - github.event.label.name == 'awaiting_tech_review' || - github.event.label.name == 'publish' + if: false runs-on: ubuntu-latest steps: diff --git a/.github/workflows/update-roadmap-project-dates.yml b/.github/workflows/update-roadmap-project-dates.yml deleted file mode 100644 index ebdf49948e..0000000000 --- a/.github/workflows/update-roadmap-project-dates.yml +++ /dev/null @@ -1,195 +0,0 @@ -name: Update Roadmap Dates - -on: - workflow_run: - workflows: - - Dispatch Roadmap Update - types: - - completed - - -jobs: - update-roadmap-dates: - runs-on: ubuntu-latest - if: | - github.event.label.name == 'awaiting_tech_review' || - github.event.label.name == 'publish' - - permissions: - contents: read - pull-requests: read - repository-projects: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - - - name: Install Octokit - run: npm install @octokit/rest - - - name: Debug Token - run: echo "Token is set" - env: - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} - - - name: Update Project Board Dates - uses: actions/github-script@v6 - with: - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} - script: | - const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit({ auth:process.env.GITHUB_TOKEN }); - - const projectNumber = 4; // Your project number - const orgName = 'ArmDeveloperEcosystem'; - const prNumber = context.payload.pull_request.number; - const labelName = context.payload.label.name; - - async function getProjectItemForPR() { - // Get the project ID - const projectQuery = ` - query { - organization(login:"${orgName}") { - projectV2(number:${projectNumber}) { - id - } - } - } - `; - - const projectResponse = await octokit.graphql(projectQuery); - const projectId = projectResponse.organization.projectV2.id; - - // Find the PR in the project - const prQuery = ` - query { - organization(login:"${orgName}") { - projectV2(number:${projectNumber}) { - items(first:100) { - nodes { - id - content { - ... on PullRequest { - number - repository { - name - } - } - } - } - } - } - } - } - `; - - const prResponse = await octokit.graphql(prQuery); - const items = prResponse.organization.projectV2.items.nodes; - - // Find the item that corresponds to this PR - const item = items.find(item => - item.content && - item.content.number === prNumber && - item.content.repository.name === context.repo.repo - ); - - return { projectId, itemId:item ? item.id:null }; - } - - async function getFieldId(projectId, fieldName) { - const fieldsQuery = ` - query { - node(id:"${projectId}") { - ... on ProjectV2 { - fields(first:20) { - nodes { - ... on ProjectV2Field { - id - name - } - ... on ProjectV2IterationField { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - } - ... on ProjectV2DateField { - id - name - } - } - } - } - } - } - `; - - const fieldsResponse = await octokit.graphql(fieldsQuery); - const fields = fieldsResponse.node.fields.nodes; - const field = fields.find(f => f.name === fieldName); - - return field ? field.id :null; - } - - async function updateDateField(projectId, itemId, fieldId, date) { - const mutation = ` - mutation { - updateProjectV2ItemFieldValue( - input:{ - projectId:"${projectId}" - itemId:"${itemId}" - fieldId:"${fieldId}" - value:{ - date:"${date}" - } - } - ) { - projectV2Item { - id - } - } - } - `; - - return await octokit.graphql(mutation); - } - - async function main() { - try { - const { projectId, itemId } = await getProjectItemForPR(); - if (!itemId) { - console.log('PR not found in project board'); - return; - } - - const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format - - if (labelName === 'awaiting_tech_review') { - const startDateFieldId = await getFieldId(projectId, 'Start Date'); - if (startDateFieldId) { - await updateDateField(projectId, itemId, startDateFieldId, today); - console.log('Updated Start Date to', today); - } else { - console.log('Start Date field not found'); - } - } else if (labelName === 'publish') { - const publishDateFieldId = await getFieldId(projectId, 'Publish Date'); - if (publishDateFieldId) { - await updateDateField(projectId, itemId, publishDateFieldId, today); - console.log('Updated Publish Date to', today); - } else { - console.log('Publish Date field not found'); - } - } - } catch (error) { - console.error('Error updating project board:', error); - core.setFailed(`Error updating project board:${error.message}`); - } - } From a183e8309772faef4c536969b4cd8c2ef648b047 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 08:28:50 +0200 Subject: [PATCH 16/41] Update condition --- .github/workflows/dispatch-roadmap-update.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index d7c5aba130..ac7a28a907 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -7,9 +7,11 @@ on: jobs: call-privileged-update: - if: false + if: | + github.event.label.name == 'awaiting_tech_review' || + github.event.label.name == 'publish' runs-on: ubuntu-latest steps: - name: Trigger Roadmap Update workflow - run: echo "Hello World" \ No newline at end of file + run: echo "Hello world" \ No newline at end of file From 50ca34a919fef84b4a93ccd88023271e93d4cb74 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 09:38:59 +0200 Subject: [PATCH 17/41] Use artifacts --- .github/workflows/dispatch-roadmap-update.yml | 11 +++++-- .github/workflows/roadmap-update.yml | 30 +++++++++++++++---- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index ac7a28a907..a660332edd 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -13,5 +13,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Trigger Roadmap Update workflow - run: echo "Hello world" \ No newline at end of file + - name: Generate and upload PR context + run: | + echo "pr_number: ${{ github.event.pull_request.number }}" > pr-context.yml + echo "label: ${{ github.event.label.name }}" >> pr-context.yml + echo "repo: ${{ github.repository }}" >> pr-context.yml + - uses: actions/upload-artifact@v4 + with: + name: pr-context + path: pr-context.yml \ No newline at end of file diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 09ac5332fa..e6fe475522 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -18,6 +18,26 @@ jobs: - name: Install Octokit run: npm install @octokit/rest + - name: Download PR context artifact + uses: actions/download-artifact@v4 + with: + name: pr-context + - name: Load PR context into env vars + run: | + echo "Loaded PR context:" + cat pr-context.yml + + pr_number=$(grep 'pr_number:' pr-context.yml | awk '{print $2}') + label=$(grep 'label:' pr-context.yml | awk '{print $2}') + repo=$(grep 'repo:' pr-context.yml | awk '{print $2}') + + echo "PR #: $pr_number" + echo "Label: $label" + echo "Repo: $repo" + + echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV + echo "PR_LABEL=$label" >> $GITHUB_ENV + echo "REPO_NAME=$repo" >> $GITHUB_ENV - name: Update Project Board Dates uses: actions/github-script@v6 @@ -27,10 +47,10 @@ jobs: const { Octokit } = require('@octokit/rest'); const octokit = new Octokit({ auth: github.token }); - const projectNumber = 4; // Your project number - const orgName = 'ArmDeveloperEcosystem'; - const prNumber = context.payload.pull_request.number; - const labelName = context.payload.label.name; + const projectNumber = 1; // Your project number + const orgName = 'annietllnd'; + const prNumber = ${{ env.PR_NUMBER }} + const labelName = ${{ env.PR_LABEL }} async function getProjectItemForPR() { // Get the project ID @@ -77,7 +97,7 @@ jobs: const item = items.find(item => item.content && item.content.number === prNumber && - item.content.repository.name === context.repo.repo + item.content.repository.name === ${{ env.REPO_NAME }} ); return { projectId, itemId:item ? item.id:null }; From b2703ce6ccee2a4dd0fdc86b71fce6dbbb5279fb Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 09:45:57 +0200 Subject: [PATCH 18/41] Test workflows --- .github/workflows/roadmap-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index e6fe475522..7f9a67641f 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -194,4 +194,4 @@ jobs: console.error('Error updating project board:', error); core.setFailed(`Error updating project board:${error.message}`); } - } \ No newline at end of file + } From fe2ebd12a9d18a6ad30d790cc3a217409ec11563 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 12:15:10 +0200 Subject: [PATCH 19/41] Add permissions --- .github/workflows/roadmap-update.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 7f9a67641f..28da6e3d47 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -6,6 +6,10 @@ on: types: - completed +permissions: + actions: read + contents: read + jobs: update-project: runs-on: ubuntu-latest From d959574a0bbc060b059ae11ff528a49711b0cb30 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:07:09 +0200 Subject: [PATCH 20/41] Add debug step --- .github/workflows/dispatch-roadmap-update.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index a660332edd..c61cf3d1e1 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -1,7 +1,7 @@ name: Dispatch Roadmap Update on: - pull_request: + pull_request_target: types: - labeled @@ -13,6 +13,14 @@ jobs: runs-on: ubuntu-latest steps: + - name: Check if PROJECT_TOKEN is available + run: | + if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then + echo "❌ PROJECT_TOKEN is not set or is empty" + exit 1 + else + echo "✅ PROJECT_TOKEN is present" + fi - name: Generate and upload PR context run: | echo "pr_number: ${{ github.event.pull_request.number }}" > pr-context.yml From 32500bd0f9de856574740b0fc90a9f52d4a865a5 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:20:36 +0200 Subject: [PATCH 21/41] Retry project token --- .github/workflows/dispatch-roadmap-update.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index c61cf3d1e1..254bac42f6 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -29,4 +29,16 @@ jobs: - uses: actions/upload-artifact@v4 with: name: pr-context - path: pr-context.yml \ No newline at end of file + path: pr-context.yml + - name: Dispatch update-project-dates + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.PROJECT_TOKEN }} + repository: ArmDeveloperEcosystem/arm-learning-paths + event-type: update-project-dates + client-payload: >- + { + "pr_number": ${{ github.event.pull_request.number }}, + "label": "${{ github.event.label.name }}", + "repo": "${{ github.repository }}" + } \ No newline at end of file From 8df4597891383757481d0909c6c21544c9bdaa5c Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:28:59 +0200 Subject: [PATCH 22/41] Merge workflows --- .github/workflows/dispatch-roadmap-update.yml | 11 ---- .github/workflows/roadmap-update.yml | 58 ++++++++----------- 2 files changed, 24 insertions(+), 45 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index 254bac42f6..d79634d401 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -2,8 +2,6 @@ name: Dispatch Roadmap Update on: pull_request_target: - types: - - labeled jobs: call-privileged-update: @@ -21,15 +19,6 @@ jobs: else echo "✅ PROJECT_TOKEN is present" fi - - name: Generate and upload PR context - run: | - echo "pr_number: ${{ github.event.pull_request.number }}" > pr-context.yml - echo "label: ${{ github.event.label.name }}" >> pr-context.yml - echo "repo: ${{ github.repository }}" >> pr-context.yml - - uses: actions/upload-artifact@v4 - with: - name: pr-context - path: pr-context.yml - name: Dispatch update-project-dates uses: peter-evans/repository-dispatch@v3 with: diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 28da6e3d47..4f1822ba6e 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -1,20 +1,25 @@ -name: Privileged Update Roadmap Dates +name: Update Roadmap Dates on: - workflow_run: - workflows: ["Dispatch Roadmap Update"] - types: - - completed - -permissions: - actions: read - contents: read + pull_request_target: + types: [labeled] jobs: - update-project: + update-roadmap-dates: runs-on: ubuntu-latest + if: | + github.event.label.name == 'awaiting_tech_review' || + github.event.label.name == 'publish' + + permissions: + contents: read + pull-requests: read + repository-projects: write steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup Node.js uses: actions/setup-node@v3 with: @@ -22,26 +27,11 @@ jobs: - name: Install Octokit run: npm install @octokit/rest - - name: Download PR context artifact - uses: actions/download-artifact@v4 - with: - name: pr-context - - name: Load PR context into env vars - run: | - echo "Loaded PR context:" - cat pr-context.yml - pr_number=$(grep 'pr_number:' pr-context.yml | awk '{print $2}') - label=$(grep 'label:' pr-context.yml | awk '{print $2}') - repo=$(grep 'repo:' pr-context.yml | awk '{print $2}') - - echo "PR #: $pr_number" - echo "Label: $label" - echo "Repo: $repo" - - echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV - echo "PR_LABEL=$label" >> $GITHUB_ENV - echo "REPO_NAME=$repo" >> $GITHUB_ENV + - name: Debug Token + run: echo "Token is set" + env: + PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} - name: Update Project Board Dates uses: actions/github-script@v6 @@ -49,12 +39,12 @@ jobs: github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit({ auth: github.token }); + const octokit = new Octokit({ auth:github.token }); const projectNumber = 1; // Your project number const orgName = 'annietllnd'; - const prNumber = ${{ env.PR_NUMBER }} - const labelName = ${{ env.PR_LABEL }} + const prNumber = context.payload.pull_request.number; + const labelName = context.payload.label.name; async function getProjectItemForPR() { // Get the project ID @@ -101,7 +91,7 @@ jobs: const item = items.find(item => item.content && item.content.number === prNumber && - item.content.repository.name === ${{ env.REPO_NAME }} + item.content.repository.name === context.repo.repo ); return { projectId, itemId:item ? item.id:null }; @@ -198,4 +188,4 @@ jobs: console.error('Error updating project board:', error); core.setFailed(`Error updating project board:${error.message}`); } - } + } \ No newline at end of file From b1b61b22d4c1235234383273b8b5ed3b5eeaa460 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:30:15 +0200 Subject: [PATCH 23/41] Disable dispatch workflow --- .github/workflows/dispatch-roadmap-update.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml index d79634d401..9963e45850 100644 --- a/.github/workflows/dispatch-roadmap-update.yml +++ b/.github/workflows/dispatch-roadmap-update.yml @@ -5,9 +5,7 @@ on: jobs: call-privileged-update: - if: | - github.event.label.name == 'awaiting_tech_review' || - github.event.label.name == 'publish' + if: false runs-on: ubuntu-latest steps: From b054bdd120a423e0f1b05ebaea615b1e8ca70d83 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:43:10 +0200 Subject: [PATCH 24/41] Change capitalization of labels --- .github/workflows/roadmap-update.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 4f1822ba6e..eacd0bb4d9 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -168,20 +168,20 @@ jobs: const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format if (labelName === 'awaiting_tech_review') { - const startDateFieldId = await getFieldId(projectId, 'Start Date'); + const startDateFieldId = await getFieldId(projectId, 'Start date'); if (startDateFieldId) { await updateDateField(projectId, itemId, startDateFieldId, today); - console.log('Updated Start Date to', today); + console.log('Updated Start date to', today); } else { - console.log('Start Date field not found'); + console.log('Start date field not found'); } } else if (labelName === 'publish') { - const publishDateFieldId = await getFieldId(projectId, 'Publish Date'); + const publishDateFieldId = await getFieldId(projectId, 'End date'); if (publishDateFieldId) { await updateDateField(projectId, itemId, publishDateFieldId, today); - console.log('Updated Publish Date to', today); + console.log('Updated End date to', today); } else { - console.log('Publish Date field not found'); + console.log('End date field not found'); } } } catch (error) { From 7ce207d594c666bce7c562ac72abfb640fa01d4d Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:47:09 +0200 Subject: [PATCH 25/41] Remove debug step --- .github/workflows/roadmap-update.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index eacd0bb4d9..a4cedfbca8 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -19,20 +19,12 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Node.js uses: actions/setup-node@v3 with: node-version: '18.x' - - name: Install Octokit run: npm install @octokit/rest - - - name: Debug Token - run: echo "Token is set" - env: - PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }} - - name: Update Project Board Dates uses: actions/github-script@v6 with: From fbb8fda90e3a698c210614aba9d913df54c938e2 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:51:34 +0200 Subject: [PATCH 26/41] Debug label --- .github/workflows/roadmap-update.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index a4cedfbca8..e3ee2c805b 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -175,6 +175,8 @@ jobs: } else { console.log('End date field not found'); } + } else { + console.log('No action taken for label:', labelName); } } catch (error) { console.error('Error updating project board:', error); From 0600ab74cea378e785d0c52317107407934f94fe Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:56:17 +0200 Subject: [PATCH 27/41] Debug fields --- .github/workflows/roadmap-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index e3ee2c805b..8bd39ac513 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -122,6 +122,7 @@ jobs: const fieldsResponse = await octokit.graphql(fieldsQuery); const fields = fieldsResponse.node.fields.nodes; const field = fields.find(f => f.name === fieldName); + console.log('Project fields:', fields.map(f => f.name)); return field ? field.id :null; } From a1a6019f5e6c22a6c8d7e77bf891a2484cd6c4e4 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:58:40 +0200 Subject: [PATCH 28/41] Call main --- .github/workflows/roadmap-update.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 8bd39ac513..5a791c6870 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -122,7 +122,6 @@ jobs: const fieldsResponse = await octokit.graphql(fieldsQuery); const fields = fieldsResponse.node.fields.nodes; const field = fields.find(f => f.name === fieldName); - console.log('Project fields:', fields.map(f => f.name)); return field ? field.id :null; } @@ -183,4 +182,5 @@ jobs: console.error('Error updating project board:', error); core.setFailed(`Error updating project board:${error.message}`); } - } \ No newline at end of file + } + main(); \ No newline at end of file From 14b250508e6de8c0ca86ea81d55abe3487e2bafe Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 13:59:29 +0200 Subject: [PATCH 29/41] Debug solution --- .github/workflows/roadmap-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 5a791c6870..21c8df8a82 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -183,4 +183,5 @@ jobs: core.setFailed(`Error updating project board:${error.message}`); } } + // Run the main function main(); \ No newline at end of file From 7d600ec111a52bc55f239e8f00fcb97a429d2713 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:13:42 +0200 Subject: [PATCH 30/41] Disable octokit instantiation --- .github/workflows/roadmap-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 21c8df8a82..eb4b446d34 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -31,7 +31,7 @@ jobs: github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit({ auth:github.token }); + //const octokit = new Octokit({ auth:github.token }); const projectNumber = 1; // Your project number const orgName = 'annietllnd'; From 1db3d90e50cf0f38b99ceededfd3e35e04fae399 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:14:29 +0200 Subject: [PATCH 31/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index eb4b446d34..aecba1e61e 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -183,5 +183,4 @@ jobs: core.setFailed(`Error updating project board:${error.message}`); } } - // Run the main function main(); \ No newline at end of file From 7d149db39596d938fea744301185fd07c0380d99 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:20:19 +0200 Subject: [PATCH 32/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index aecba1e61e..199788ed5e 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -31,7 +31,7 @@ jobs: github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - //const octokit = new Octokit({ auth:github.token }); + const octokit = new Octokit(); const projectNumber = 1; // Your project number const orgName = 'annietllnd'; From a989892014ce8d8078268f12d46f0ec6413ea20d Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:21:16 +0200 Subject: [PATCH 33/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 199788ed5e..019318bcce 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -32,7 +32,6 @@ jobs: script: | const { Octokit } = require('@octokit/rest'); const octokit = new Octokit(); - const projectNumber = 1; // Your project number const orgName = 'annietllnd'; const prNumber = context.payload.pull_request.number; From fd86e0a870839030a9a71d4b36e4f3ebc3dc210c Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:29:57 +0200 Subject: [PATCH 34/41] Use github authentication --- .github/workflows/roadmap-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 019318bcce..ec09def451 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -31,7 +31,7 @@ jobs: github-token: ${{ secrets.PROJECT_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit(); + const octokit = github; const projectNumber = 1; // Your project number const orgName = 'annietllnd'; const prNumber = context.payload.pull_request.number; From 37c1f7c90eca014e1fc86d2872fee369caa12c17 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:30:34 +0200 Subject: [PATCH 35/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index ec09def451..9dbf7c378f 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -32,6 +32,7 @@ jobs: script: | const { Octokit } = require('@octokit/rest'); const octokit = github; + const projectNumber = 1; // Your project number const orgName = 'annietllnd'; const prNumber = context.payload.pull_request.number; From 286145adc9e28192580ee8470a6aba40782a6e18 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:41:16 +0200 Subject: [PATCH 36/41] Change from org to viewer --- .github/workflows/roadmap-update.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 9dbf7c378f..9defd43f75 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -41,22 +41,22 @@ jobs: async function getProjectItemForPR() { // Get the project ID const projectQuery = ` - query { - organization(login:"${orgName}") { - projectV2(number:${projectNumber}) { - id - } + query { + viewer { + projectV2(number:${projectNumber}) { + id } } - `; + } + `; const projectResponse = await octokit.graphql(projectQuery); - const projectId = projectResponse.organization.projectV2.id; + const projectId = projectResponse.viewer.projectV2.id; // Find the PR in the project const prQuery = ` query { - organization(login:"${orgName}") { + viewer(login:"${orgName}") { projectV2(number:${projectNumber}) { items(first:100) { nodes { @@ -77,7 +77,7 @@ jobs: `; const prResponse = await octokit.graphql(prQuery); - const items = prResponse.organization.projectV2.items.nodes; + const items = prResponse.viewer.projectV2.items.nodes; // Find the item that corresponds to this PR const item = items.find(item => From 4c7bb0daa91beba50b49acb98debf82951b1538d Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:42:39 +0200 Subject: [PATCH 37/41] Remove orgName --- .github/workflows/roadmap-update.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 9defd43f75..3ba764212d 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -34,7 +34,6 @@ jobs: const octokit = github; const projectNumber = 1; // Your project number - const orgName = 'annietllnd'; const prNumber = context.payload.pull_request.number; const labelName = context.payload.label.name; @@ -56,7 +55,7 @@ jobs: // Find the PR in the project const prQuery = ` query { - viewer(login:"${orgName}") { + viewer { projectV2(number:${projectNumber}) { items(first:100) { nodes { From c63f18322320d22826e692801d0a78318109d546 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:44:36 +0200 Subject: [PATCH 38/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 3ba764212d..14e6d0c771 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -37,6 +37,7 @@ jobs: const prNumber = context.payload.pull_request.number; const labelName = context.payload.label.name; + async function getProjectItemForPR() { // Get the project ID const projectQuery = ` From f148080fc7489f6c7fe0edd5c4f6cc0bd49adef9 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:51:06 +0200 Subject: [PATCH 39/41] Update date field --- .github/workflows/roadmap-update.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 14e6d0c771..c94cfbc0ab 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -90,7 +90,7 @@ jobs: } async function getFieldId(projectId, fieldName) { - const fieldsQuery = ` + const fieldsQuery = ` query { node(id:"${projectId}") { ... on ProjectV2 { @@ -99,18 +99,7 @@ jobs: ... on ProjectV2Field { id name - } - ... on ProjectV2IterationField { - id - name - } - ... on ProjectV2SingleSelectField { - id - name - } - ... on ProjectV2DateField { - id - name + dataType } } } @@ -121,9 +110,9 @@ jobs: const fieldsResponse = await octokit.graphql(fieldsQuery); const fields = fieldsResponse.node.fields.nodes; - const field = fields.find(f => f.name === fieldName); + const field = fields.find(f => f.name === fieldName && f.dataType === 'DATE'); - return field ? field.id :null; + return field ? field.id : null; } async function updateDateField(projectId, itemId, fieldId, date) { From ed6a543c1264ec686fbf0be6ddd9ed250f6fce51 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 14:52:01 +0200 Subject: [PATCH 40/41] Update roadmap-update.yml --- .github/workflows/roadmap-update.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index c94cfbc0ab..9ce8af762d 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -23,6 +23,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: '18.x' + - name: Install Octokit run: npm install @octokit/rest - name: Update Project Board Dates From 5a5f025fbd9cd3e71f31eb6bf86299f1d3b9aad3 Mon Sep 17 00:00:00 2001 From: Annie Tallund Date: Tue, 6 May 2025 15:02:30 +0200 Subject: [PATCH 41/41] Adapt workflow to main repository --- .github/workflows/dispatch-roadmap-update.yml | 31 ---- .github/workflows/roadmap-update.yml | 132 ++++++++++-------- 2 files changed, 73 insertions(+), 90 deletions(-) delete mode 100644 .github/workflows/dispatch-roadmap-update.yml diff --git a/.github/workflows/dispatch-roadmap-update.yml b/.github/workflows/dispatch-roadmap-update.yml deleted file mode 100644 index 9963e45850..0000000000 --- a/.github/workflows/dispatch-roadmap-update.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Dispatch Roadmap Update - -on: - pull_request_target: - -jobs: - call-privileged-update: - if: false - runs-on: ubuntu-latest - - steps: - - name: Check if PROJECT_TOKEN is available - run: | - if [ -z "${{ secrets.PROJECT_TOKEN }}" ]; then - echo "❌ PROJECT_TOKEN is not set or is empty" - exit 1 - else - echo "✅ PROJECT_TOKEN is present" - fi - - name: Dispatch update-project-dates - uses: peter-evans/repository-dispatch@v3 - with: - token: ${{ secrets.PROJECT_TOKEN }} - repository: ArmDeveloperEcosystem/arm-learning-paths - event-type: update-project-dates - client-payload: >- - { - "pr_number": ${{ github.event.pull_request.number }}, - "label": "${{ github.event.label.name }}", - "repo": "${{ github.repository }}" - } \ No newline at end of file diff --git a/.github/workflows/roadmap-update.yml b/.github/workflows/roadmap-update.yml index 9ce8af762d..aa4700b51d 100644 --- a/.github/workflows/roadmap-update.yml +++ b/.github/workflows/roadmap-update.yml @@ -1,4 +1,4 @@ -name: Update Roadmap Dates +name: Update Roadmap Date on: pull_request_target: @@ -19,6 +19,7 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Setup Node.js uses: actions/setup-node@v3 with: @@ -26,76 +27,88 @@ jobs: - name: Install Octokit run: npm install @octokit/rest + - name: Update Project Board Dates uses: actions/github-script@v6 with: github-token: ${{ secrets.PROJECT_TOKEN }} script: | - const { Octokit } = require('@octokit/rest'); const octokit = github; - const projectNumber = 1; // Your project number + const projectNumber = 4; + const orgLogin = 'ArmDeveloperEcosystem'; const prNumber = context.payload.pull_request.number; const labelName = context.payload.label.name; - async function getProjectItemForPR() { - // Get the project ID const projectQuery = ` - query { - viewer { - projectV2(number:${projectNumber}) { - id + query { + organization(login: "${orgLogin}") { + projectV2(number: ${projectNumber}) { + id + } } } - } - `; - + `; const projectResponse = await octokit.graphql(projectQuery); - const projectId = projectResponse.viewer.projectV2.id; - - // Find the PR in the project - const prQuery = ` - query { - viewer { - projectV2(number:${projectNumber}) { - items(first:100) { - nodes { - id - content { - ... on PullRequest { - number - repository { - name + const project = projectResponse.organization?.projectV2; + if (!project) throw new Error("Project not found for organization."); + const projectId = project.id; + + let cursor = null; + let itemId = null; + do { + const prQuery = ` + query($after: String) { + organization(login: "${orgLogin}") { + projectV2(number: ${projectNumber}) { + items(first: 100, after: $after) { + nodes { + id + content { + ... on PullRequest { + number + repository { + name + } } } } + pageInfo { + hasNextPage + endCursor + } } } } } + `; + const prResponse = await octokit.graphql(prQuery, { after: cursor }); + const items = prResponse.organization.projectV2.items.nodes; + + const foundItem = items.find(item => + item.content && + item.content.number === prNumber && + item.content.repository.name === context.repo.repo + ); + + if (foundItem) { + itemId = foundItem.id; + break; } - `; - - const prResponse = await octokit.graphql(prQuery); - const items = prResponse.viewer.projectV2.items.nodes; - // Find the item that corresponds to this PR - const item = items.find(item => - item.content && - item.content.number === prNumber && - item.content.repository.name === context.repo.repo - ); + cursor = prResponse.organization.projectV2.items.pageInfo.endCursor; + } while (cursor); - return { projectId, itemId:item ? item.id:null }; + return { projectId, itemId }; } async function getFieldId(projectId, fieldName) { const fieldsQuery = ` query { - node(id:"${projectId}") { + node(id: "${projectId}") { ... on ProjectV2 { - fields(first:20) { + fields(first: 50) { nodes { ... on ProjectV2Field { id @@ -110,7 +123,7 @@ jobs: `; const fieldsResponse = await octokit.graphql(fieldsQuery); - const fields = fieldsResponse.node.fields.nodes; + const fields = fieldsResponse.node?.fields?.nodes || []; const field = fields.find(f => f.name === fieldName && f.dataType === 'DATE'); return field ? field.id : null; @@ -120,13 +133,11 @@ jobs: const mutation = ` mutation { updateProjectV2ItemFieldValue( - input:{ - projectId:"${projectId}" - itemId:"${itemId}" - fieldId:"${fieldId}" - value:{ - date:"${date}" - } + input: { + projectId: "${projectId}" + itemId: "${itemId}" + fieldId: "${fieldId}" + value: { date: "${date}" } } ) { projectV2Item { @@ -136,7 +147,9 @@ jobs: } `; - return await octokit.graphql(mutation); + const result = await octokit.graphql(mutation); + console.log('Mutation result:', result); + return result; } async function main() { @@ -147,30 +160,31 @@ jobs: return; } - const today = new Date().toISOString().split('T')[0]; // YYYY-MM-DD format + const today = new Date().toISOString().split('T')[0]; if (labelName === 'awaiting_tech_review') { - const startDateFieldId = await getFieldId(projectId, 'Start date'); + const startDateFieldId = await getFieldId(projectId, 'Start Date'); if (startDateFieldId) { await updateDateField(projectId, itemId, startDateFieldId, today); - console.log('Updated Start date to', today); + console.log('Updated Start Date to', today); } else { - console.log('Start date field not found'); + console.log('⚠️ Start Date field not found'); } } else if (labelName === 'publish') { - const publishDateFieldId = await getFieldId(projectId, 'End date'); - if (publishDateFieldId) { - await updateDateField(projectId, itemId, publishDateFieldId, today); - console.log('Updated End date to', today); + const endDateFieldId = await getFieldId(projectId, 'Publish Date'); + if (endDateFieldId) { + await updateDateField(projectId, itemId, endDateFieldId, today); + console.log('Updated Publish Date to', today); } else { - console.log('End date field not found'); + console.log('Publish Date field not found'); } } else { console.log('No action taken for label:', labelName); } } catch (error) { console.error('Error updating project board:', error); - core.setFailed(`Error updating project board:${error.message}`); + core.setFailed(`Error updating project board: ${error.message}`); } } + main(); \ No newline at end of file