Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/.release-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
${{ startsWith(github.ref, 'refs/heads/release/') }}
steps:
# Checks-out the develop branch
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
ref: 'refs/heads/develop'
- uses: actions/setup-python@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
source: ${{ steps.build-outputs.outputs.source }}

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Needed for proper versioning

Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0

Expand Down
129 changes: 129 additions & 0 deletions .github/workflows/org-add-to-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# used to triage new issues and PRs on project board, so not to miss external feedback or contributions of users.
name: Add to PODAAC Project


on:
issues:
types: [opened]
pull_request:
types: [opened]

Comment on lines +5 to +10
jobs:
add-to-project:
runs-on: ubuntu-latest
steps:
- name: Add to project
uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/podaac/projects/75
github-token: ${{ secrets.PROJECTS_PAT }}

- name: Set status to needs:triage
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJECTS_PAT }}
script: |
const projectNumber = 75; // Update this with your actual project number
const org = 'podaac';

// Get the project ID
const projectQuery = `
query($org: String!, $number: Int!) {
organization(login: $org) {
projectV2(number: $number) {
id
fields(first: 20) {
nodes {
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}
`;

const projectData = await github.graphql(projectQuery, {
org: org,
number: projectNumber
});

const project = projectData.organization.projectV2;
const statusField = project.fields.nodes.find(field => field.name === 'Status');
const triageOption = statusField?.options.find(option => option.name === 'needs:triage');

if (!triageOption) {
core.warning('Could not find "needs:triage" status option');
return;
}

// Get the item ID that was just added
const itemType = context.eventName === 'issues' ? 'Issue' : 'PullRequest';
const itemNumber = context.payload.issue?.number || context.payload.pull_request?.number;

const itemQuery = `
query($org: String!, $repo: String!, $number: Int!) {
repository(owner: $org, name: $repo) {
${itemType === 'Issue' ? 'issue' : 'pullRequest'}(number: $number) {
projectItems(first: 10) {
nodes {
id
project {
id
}
}
}
}
}
}
`;

const itemData = await github.graphql(itemQuery, {
org: org,
repo: context.repo.repo,
number: itemNumber
});

const items = itemType === 'Issue'
? itemData.repository.issue.projectItems.nodes
: itemData.repository.pullRequest.projectItems.nodes;

const projectItem = items.find(item => item.project.id === project.id);

if (!projectItem) {
core.warning('Could not find project item');
return;
}

// Update the status field
const updateMutation = `
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(
input: {
projectId: $projectId
itemId: $itemId
fieldId: $fieldId
value: { singleSelectOptionId: $value }
}
) {
projectV2Item {
id
}
}
}
`;

await github.graphql(updateMutation, {
projectId: project.id,
itemId: projectItem.id,
fieldId: statusField.id,
value: triageOption.id
});

core.info('Successfully set status to needs:triage');
127 changes: 127 additions & 0 deletions .github/workflows/org-close-pr-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Directly move the closed PR to a close status in the PODAAC project
# to avoid unnecessary clutter and manual triage in the "needs:triage" column.
name: Update Closed PR Status in PODAAC project

on:
pull_request:
types: [closed]

Comment on lines +5 to +8
jobs:
update-pr-status:
runs-on: ubuntu-latest
steps:
- name: Set status to closed
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PROJECTS_PAT }}
script: |
const projectNumber = 75;
const org = 'podaac';
const prNumber = context.payload.pull_request.number;
const isMerged = context.payload.pull_request.merged;

console.log(`PR #${prNumber} was ${isMerged ? 'merged' : 'closed without merging'}`);

// Get the project ID and status field information
const projectQuery = `
query($org: String!, $number: Int!) {
organization(login: $org) {
projectV2(number: $number) {
id
fields(first: 20) {
nodes {
... on ProjectV2SingleSelectField {
id
name
options {
id
name
}
}
}
}
}
}
}
`;

const projectData = await github.graphql(projectQuery, {
org: org,
number: projectNumber
});

const project = projectData.organization.projectV2;
const statusField = project.fields.nodes.find(field => field.name === 'Status');
const closedOption = statusField?.options.find(option => option.name === 'closed');

if (!closedOption) {
core.warning('Could not find "closed" status option in project');
return;
}

// Get the PR's project item
const itemQuery = `
query($org: String!, $repo: String!, $number: Int!) {
repository(owner: $org, name: $repo) {
pullRequest(number: $number) {
projectItems(first: 10) {
nodes {
id
project {
id
}
}
}
}
}
}
`;

const itemData = await github.graphql(itemQuery, {
org: org,
repo: context.repo.repo,
number: prNumber
});

const items = itemData.repository.pullRequest.projectItems.nodes;
const projectItem = items.find(item => item.project.id === project.id);

if (!projectItem) {
console.log('PR is not in the project, skipping status update');
return;
}

// Update the status field to "closed"
const updateMutation = `
mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(
input: {
projectId: $projectId
itemId: $itemId
fieldId: $fieldId
value: { singleSelectOptionId: $value }
}
) {
projectV2Item {
id
}
}
}
`;

await github.graphql(updateMutation, {
projectId: project.id,
itemId: projectItem.id,
fieldId: statusField.id,
value: closedOption.id
});

console.log(`✅ Successfully set status to "closed" for PR #${prNumber}`);

core.summary
.addHeading(`PR Status Updated`)
.addList([
`PR #${prNumber} was ${isMerged ? 'merged' : 'closed'}`,
`Project status updated to "closed"`
])
.write();
Loading
Loading