Update project_automation.yml
This commit is contained in:
parent
596bb7111b
commit
2033498627
|
|
@ -67,10 +67,10 @@ jobs:
|
|||
resource_node_id: ${{ github.event.pull_request.node_id }}
|
||||
status_value: ${{ env.in_review }}
|
||||
|
||||
issue_closed:
|
||||
name: issue_closed
|
||||
issue_or_pr_closed:
|
||||
name: issue_or_pr_closed
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'issues' && github.event.action == 'closed'
|
||||
if: (github.event_name == 'issues' || github.event_name == 'pull_request') && github.event.action == 'closed'
|
||||
steps:
|
||||
- name: Check Close Reason and Update
|
||||
id: close-reason
|
||||
|
|
@ -83,7 +83,18 @@ jobs:
|
|||
const isIssue = context.eventName === 'issues';
|
||||
const nodeId = isIssue ? context.payload.issue.node_id : context.payload.pull_request.node_id;
|
||||
|
||||
// Log context for debugging
|
||||
console.log(`Event: ${context.eventName}, Issue/PR Number: ${issueNumber}`);
|
||||
console.log(`Repo Owner: ${repo.owner}, Repo Name: ${repo.repo}`);
|
||||
console.log(`Node ID: ${nodeId}`);
|
||||
|
||||
// Validate inputs
|
||||
if (!issueNumber || !repo.owner || !repo.repo) {
|
||||
throw new Error('Missing required context: issueNumber, repo.owner, or repo.repo');
|
||||
}
|
||||
|
||||
// Get issue/PR details
|
||||
try {
|
||||
const { data: issue } = await github.rest.issues.get({
|
||||
owner: repo.owner,
|
||||
repo: repo.repo,
|
||||
|
|
@ -128,6 +139,24 @@ jobs:
|
|||
// Archive the project item if needed (not supported by project-beta-automations)
|
||||
if (shouldArchive) {
|
||||
try {
|
||||
// Fetch project node ID
|
||||
const projectData = await github.graphql(`
|
||||
query($org: String!, $projectNumber: Int!) {
|
||||
organization(login: $org) {
|
||||
projectV2(number: $projectNumber) {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
org: 'ghostbsd',
|
||||
projectNumber: 4
|
||||
});
|
||||
|
||||
const projectId = projectData.organization.projectV2.id;
|
||||
console.log(`Project ID: ${projectId}`);
|
||||
|
||||
// Fetch project items
|
||||
const projectItems = await github.graphql(`
|
||||
query($org: String!, $projectNumber: Int!) {
|
||||
organization(login: $org) {
|
||||
|
|
@ -159,14 +188,15 @@ jobs:
|
|||
|
||||
if (projectItem) {
|
||||
await github.graphql(`
|
||||
mutation($itemId: ID!) {
|
||||
archiveProjectV2Item(input: { projectId: "${process.env.PROJECT_ID}", itemId: $itemId }) {
|
||||
mutation($projectId: ID!, $itemId: ID!) {
|
||||
archiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
||||
item {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
projectId: projectId,
|
||||
itemId: projectItem.id
|
||||
});
|
||||
console.log(`Archived item with node ID ${nodeId} in project 4`);
|
||||
|
|
@ -179,6 +209,10 @@ jobs:
|
|||
}
|
||||
|
||||
core.setOutput('close_reason', closeReason);
|
||||
} catch (error) {
|
||||
console.log(`Failed to fetch issue/PR: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
|
||||
- name: Move to Project Board
|
||||
if: steps.close-reason.outputs.status_value
|
||||
|
|
|
|||
Loading…
Reference in New Issue