-
Notifications
You must be signed in to change notification settings - Fork 80
ci(actions): add action to remove issues from design projects #11249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
DitwanP
merged 15 commits into
dev
from
dit13711/10327-automate-archiving-issues-in-design-projects
Jan 16, 2025
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9bf4d0c
ci(actions): add action to archive issues in design projects
DitwanP 06e9bfb
cleanup log messages
DitwanP 1bd5b85
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP c916081
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP f30b523
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP af1ed63
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP 7748e83
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP 5e7c11b
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP 4f843b1
Merge branch 'dev' into dit13711/10327-automate-archiving-issues-in-d…
DitwanP f7dfff6
Merge branch 'dev' of https://github.com/Esri/calcite-design-system i…
DitwanP 7c8fbbe
unspecify node version
DitwanP b036e1c
add context to comment
DitwanP d143da2
Merge branch 'dev' of https://github.com/Esri/calcite-design-system i…
DitwanP 2989c51
Merge branch 'dev' of https://github.com/Esri/calcite-design-system i…
DitwanP 37f878b
remove label conditional and switch to removal instead of archiving
DitwanP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { execSync } = require("child_process"); | ||
|
||
// Environment variables from the GitHub Action | ||
const owner = process.env.OWNER; | ||
const repo = process.env.REPO; | ||
const issueNumber = process.env.ISSUE_NUMBER; | ||
const labelName = process.env.LABEL_NAME; | ||
|
||
// Function to execute a GitHub GraphQL command | ||
function runQuery(query) { | ||
const command = `gh api graphql -f query='${query}' -F owner="${owner}" -F repo="${repo}" -F issueNumber=${issueNumber}`; | ||
return execSync(command, { encoding: "utf-8" }); | ||
} | ||
|
||
// Function to create a comment | ||
async function createComment(body) { | ||
const command = `gh issue comment ${issueNumber} --body "${body}"`; | ||
return execSync(command, { encoding: "utf-8" }); | ||
} | ||
|
||
// GraphQL query to find the project associated with the issue | ||
const query = ` | ||
query($owner: String!, $repo: String!, $issueNumber: Int!) { | ||
repository(owner: $owner, name: $repo) { | ||
id | ||
nameWithOwner | ||
description | ||
issue(number: $issueNumber) { | ||
id | ||
title | ||
projectItems(first: 1) { | ||
nodes { | ||
id | ||
project { | ||
id | ||
title | ||
url | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
try { | ||
const result = runQuery(query); | ||
const parsedResult = JSON.parse(result); | ||
const projectItem = parsedResult.data.repository.issue.projectItems.nodes[0]; | ||
console.log("Project Item:", projectItem); | ||
|
||
if (projectItem) { | ||
if (labelName === "ready for dev") { | ||
const archiveQuery = `mutation { archiveProjectV2Item(input: {projectId: "${projectItem.project.id}", itemId: "${projectItem.id}"}) { clientMutationId } }`; | ||
runQuery(archiveQuery); | ||
createComment( | ||
`The design work for this issue has been completed and it is now ready for development.\n\nThe issue has been archived in the [${projectItem.project.title}](${projectItem.project.url}/archive) project.`, | ||
); | ||
console.log("Issue archived in project."); | ||
} else { | ||
console.log("No action taken, label added was not 'ready for dev'."); | ||
} | ||
} else { | ||
console.log("No associated project found for this issue."); | ||
} | ||
} catch (error) { | ||
console.error("Error:", error.message); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Archive Issue in Project | ||
|
||
on: | ||
issues: | ||
types: [labeled] | ||
|
||
jobs: | ||
process-labeled-issue: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: package.json | ||
|
||
- name: Archive Issue | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
ISSUE_NUMBER: ${{ github.event.issue.number }} | ||
LABEL_NAME: ${{ github.event.label.name }} | ||
run: node .github/scripts/archiveIssuesInDesignProjects.js |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.