-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from department-of-veterans-affairs/bp-193-re…
…view-github-actions Added github action workflows to test
- Loading branch information
Showing
6 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,33 @@ | ||
name: Add Issue to Second Project | ||
|
||
on: | ||
issues: | ||
types: [opened] | ||
|
||
jobs: | ||
add-issue-to-project: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add Issue to Secondary Project | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const projectId = 'YOUR_SECOND_PROJECT_ID'; // Replace with your target project ID | ||
const issue = context.payload.issue; | ||
const addProjectItem = await github.graphql(` | ||
mutation($projectId: ID!, $contentId: ID!) { | ||
addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) { | ||
item { | ||
id | ||
} | ||
} | ||
} | ||
`, { | ||
projectId: projectId, | ||
contentId: issue.node_id | ||
}); | ||
console.log(`Issue #${issue.number} added to project with item ID: ${addProjectItem.addProjectV2ItemById.item.id}`); |
This file contains 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,16 @@ | ||
name: Auto-label Issues | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
label-issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add Bug Label | ||
if: contains(github.event.issue.title, 'bug') | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: "bug" |
This file contains 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,16 @@ | ||
name: Track Dependencies | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
add-dependency: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add Dependency Label | ||
if: contains(github.event.issue.body, '#dependent-on') | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: "dependency" |
This file contains 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,16 @@ | ||
name: Auto-label Issues | ||
|
||
on: | ||
issues: | ||
types: [opened, edited] | ||
|
||
jobs: | ||
label-issue: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Add Bug Label | ||
if: contains(github.event.issue.title, 'bug') | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
labels: "bug" |
This file contains 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,76 @@ | ||
name: Sync Status Across Projects | ||
|
||
on: | ||
issues: | ||
types: [edited, labeled, unlabeled, closed, reopened] | ||
|
||
jobs: | ||
sync-status: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Sync Status Field | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const sourceProjectId = 'YOUR_SOURCE_PROJECT_ID'; // Replace with the source project ID | ||
const targetProjectId = 'YOUR_TARGET_PROJECT_ID'; // Replace with the target project ID | ||
const statusFieldId = 'YOUR_STATUS_FIELD_ID'; // Replace with the status field ID for both projects | ||
// Fetch the current issue status from the source project | ||
const issueNodeId = context.payload.issue.node_id; | ||
// Fetch the status field value in the source project | ||
const { resource } = await github.graphql(` | ||
query($projectId: ID!, $issueId: ID!) { | ||
node(id: $issueId) { | ||
... on Issue { | ||
projectItems(first: 10) { | ||
nodes { | ||
fieldValues(first: 10) { | ||
nodes { | ||
projectField { | ||
id | ||
} | ||
value | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, { | ||
projectId: sourceProjectId, | ||
issueId: issueNodeId | ||
}); | ||
// Extract the current status from the source project | ||
const currentStatus = resource.node.projectItems.nodes.find(item => item.projectField.id === statusFieldId)?.value; | ||
if (!currentStatus) { | ||
console.log("No status field found or status has not changed."); | ||
return; | ||
} | ||
// Update the status in the target project | ||
await github.graphql(` | ||
mutation($projectId: ID!, $contentId: ID!, $status: String!) { | ||
updateProjectV2ItemFieldValue(input: { | ||
projectId: $projectId, | ||
itemId: $contentId, | ||
fieldId: "${statusFieldId}", | ||
value: $status | ||
}) { | ||
projectV2Item { | ||
id | ||
} | ||
} | ||
} | ||
`, { | ||
projectId: targetProjectId, | ||
contentId: issueNodeId, | ||
status: currentStatus | ||
}); | ||
console.log(`Status synced successfully to target project for issue ID: ${issueNodeId}`); |
This file contains 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,16 @@ | ||
name: Update Issue Status | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
|
||
jobs: | ||
update-status: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Update Issue Status to "Done" | ||
uses: actions-ecosystem/action-update-comment@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
issue_number: ${{ github.event.issue.number }} | ||
comment: "Status: Done" |