Skip to content

LP ONNX Runtime on WoA #18

LP ONNX Runtime on WoA

LP ONNX Runtime on WoA #18

name: Update Project Fields on Label and Status Change
on:
pull_request:
types:
- labeled
workflow_dispatch:
jobs:
update-project-dates:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Run GitHub Script
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # replace with your token secret name
script: |
const projectId = "PVT_kwDOBVR2-M4A2QVf"; // Replace with your actual project node ID
const fieldStartId = "PVTF_lADOBVR2-M4A2QVfzgrvSF4"; // Replace with Start Date field node ID
const fieldPublishId = "PVTF_lADOBVR2-M4A2QVfzgrvSMA"; // Replace with Publish Date field node ID
const label = context.payload.label ? context.payload.label.name : null;
if (!label) {
console.log("No label found in the payload.");
return;
}
const prNodeId = context.payload.pull_request.node_id;
// Get the project item for this PR
const { repository } = await github.graphql(`
query($owner: String!, $repo: String!, $prNumber: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $prNumber) {
projectItems(first: 10) {
nodes {
id
fieldValues(first: 10) {
nodes {
field {
name
}
... on ProjectV2ItemFieldDateValue {
date
}
... on ProjectV2ItemFieldTextValue {
text
}
... on ProjectV2ItemFieldSingleSelectValue {
name
}
}
}
}
}
`, {
owner: context.repo.owner,
repo: context.repo.repo,
prNumber: context.issue.number,
});
const item = repository.pullRequest.projectItems.nodes[0];
if (!item) {
console.log("No project item found for this PR.");
return;
}
const itemId = item.id;
const today = new Date().toISOString().split("T")[0]; // e.g., "2025-04-10"
if (label === "awaiting_tech_review") {
console.log("Setting Start Date...");
await github.graphql(`
mutation {
updateProjectV2ItemFieldValue(input: {
projectId: "${projectId}",
itemId: "${itemId}",
fieldId: "${fieldStartId}",
value: { date: "${today}" }
}) {
projectV2Item {
id
}
}
}
`);
}
if (label === "publish") {
console.log("Setting Publish Date...");
await github.graphql(`
mutation {
updateProjectV2ItemFieldValue(input: {
projectId: "${projectId}",
itemId: "${itemId}",
fieldId: "${fieldPublishId}",
value: { date: "${today}" }
}) {
projectV2Item {
id
}
}
}
`);
}