Skip to content
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b41d9c7
Update roadmap workflow
annietllnd Apr 24, 2025
9ef5ba2
Update roadmap workflow
annietllnd Apr 24, 2025
a1929fe
Test dispatched solution
annietllnd Apr 24, 2025
4f66f41
Use pull_request_target event
annietllnd Apr 24, 2025
84577b4
Change token
annietllnd May 5, 2025
2ed338c
Restore current workflow
annietllnd May 5, 2025
93ed964
Add debug step for dispatch
annietllnd May 5, 2025
2c17c12
Test comment approach
annietllnd May 5, 2025
22da50e
Revert comment approach
annietllnd May 5, 2025
0c1a8a1
Change trigger type
annietllnd May 5, 2025
fc52d04
Update types list
annietllnd May 5, 2025
1b7a9fb
Use webhook approach
annietllnd May 5, 2025
c39e68d
Trigger existing workflow
annietllnd May 5, 2025
fd17948
Update call
annietllnd May 5, 2025
3ee84b2
Add workflows for testing
annietllnd May 5, 2025
a183e83
Update condition
annietllnd May 6, 2025
50ca34a
Use artifacts
annietllnd May 6, 2025
b2703ce
Test workflows
annietllnd May 6, 2025
fe2ebd1
Add permissions
annietllnd May 6, 2025
d959574
Add debug step
annietllnd May 6, 2025
32500bd
Retry project token
annietllnd May 6, 2025
8df4597
Merge workflows
annietllnd May 6, 2025
b1b61b2
Disable dispatch workflow
annietllnd May 6, 2025
b054bdd
Change capitalization of labels
annietllnd May 6, 2025
7ce207d
Remove debug step
annietllnd May 6, 2025
fbb8fda
Debug label
annietllnd May 6, 2025
0600ab7
Debug fields
annietllnd May 6, 2025
a1a6019
Call main
annietllnd May 6, 2025
14b2505
Debug solution
annietllnd May 6, 2025
7d600ec
Disable octokit instantiation
annietllnd May 6, 2025
1db3d90
Update roadmap-update.yml
annietllnd May 6, 2025
7d149db
Update roadmap-update.yml
annietllnd May 6, 2025
a989892
Update roadmap-update.yml
annietllnd May 6, 2025
fd86e0a
Use github authentication
annietllnd May 6, 2025
37c1f7c
Update roadmap-update.yml
annietllnd May 6, 2025
286145a
Change from org to viewer
annietllnd May 6, 2025
4c7bb0d
Remove orgName
annietllnd May 6, 2025
c63f183
Update roadmap-update.yml
annietllnd May 6, 2025
f148080
Update date field
annietllnd May 6, 2025
ed6a543
Update roadmap-update.yml
annietllnd May 6, 2025
5a5f025
Adapt workflow to main repository
annietllnd May 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions .github/workflows/roadmap-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
name: Update Roadmap Date

on:
pull_request_target:
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: Update Project Board Dates
uses: actions/github-script@v6
with:
github-token: ${{ secrets.PROJECT_TOKEN }}
script: |
const octokit = github;

const projectNumber = 4;
const orgLogin = 'ArmDeveloperEcosystem';
const prNumber = context.payload.pull_request.number;
const labelName = context.payload.label.name;

async function getProjectItemForPR() {
const projectQuery = `
query {
organization(login: "${orgLogin}") {
projectV2(number: ${projectNumber}) {
id
}
}
}
`;
const projectResponse = await octokit.graphql(projectQuery);
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;
}

cursor = prResponse.organization.projectV2.items.pageInfo.endCursor;
} while (cursor);

return { projectId, itemId };
}

async function getFieldId(projectId, fieldName) {
const fieldsQuery = `
query {
node(id: "${projectId}") {
... on ProjectV2 {
fields(first: 50) {
nodes {
... on ProjectV2Field {
id
name
dataType
}
}
}
}
}
}
`;

const fieldsResponse = await octokit.graphql(fieldsQuery);
const fields = fieldsResponse.node?.fields?.nodes || [];
const field = fields.find(f => f.name === fieldName && f.dataType === 'DATE');

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
}
}
}
`;

const result = await octokit.graphql(mutation);
console.log('Mutation result:', result);
return result;
}

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];

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 endDateFieldId = await getFieldId(projectId, 'Publish Date');
if (endDateFieldId) {
await updateDateField(projectId, itemId, endDateFieldId, today);
console.log('Updated Publish Date to', today);
} else {
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}`);
}
}

main();
Loading