Skip to content

fix: try project_v2_item trigger (singular) #4

fix: try project_v2_item trigger (singular)

fix: try project_v2_item trigger (singular) #4

name: Add Label on Project Status Change

Check failure on line 1 in .github/workflows/project-status-label.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/project-status-label.yaml

Invalid workflow file

(Line: 5, Col: 3): Unexpected value 'project_v2_item'
on:
workflow_dispatch:
project_v2_item:
types: [edited]
jobs:
add-label:
runs-on: ubuntu-latest
steps:
- name: Check project item status and add label
uses: actions/github-script@v7
with:
script: |
try {
const { data: item } = await github.graphql(`
query($id: ID!) {
node(id: $id) {
... on ProjectV2Item {
content {
... on Issue {
number
repository {
name
owner { login }
}
}
}
fieldValues(first: 10) {
nodes {
... on ProjectV2ItemFieldSingleSelectValue {
field { name }
name
}
}
}
}
}
}
`, { id: context.payload.project_v2_item.node_id });
const statusField = item.fieldValues.nodes.find(f => f.field.name === "Status");
console.log("current status:", statusField?.name);
if (
statusField?.name === "Need To Verify" &&
item.content?.number
) {
const issue = item.content;
await github.rest.issues.addLabels({
owner: issue.repository.owner.login,
repo: issue.repository.name,
issue_number: issue.number,
labels: ["kind/need-to-verify"]
});
console.log("Label added: kind/need-to-verify");
} else {
console.log("Not a matching item, skip");
}
} catch (error) {
console.error("Action failed:", error.message);
throw error;
}