Skip to content

Commit

Permalink
Merge pull request #197 from department-of-veterans-affairs/bp-193-re…
Browse files Browse the repository at this point in the history
…view-github-actions

Added github action workflows to test
  • Loading branch information
bellepx0 authored Nov 18, 2024
2 parents d02d793 + bc4b3b0 commit d5d7de3
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/add-issue-to-second-project.yml
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}`);
16 changes: 16 additions & 0 deletions .github/workflows/assign-user-from-label.yml
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"
16 changes: 16 additions & 0 deletions .github/workflows/link-issue-as-dependency.yml
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"
16 changes: 16 additions & 0 deletions .github/workflows/set-issue-label.yml
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"
76 changes: 76 additions & 0 deletions .github/workflows/sync-status-across-projects.yml
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}`);
16 changes: 16 additions & 0 deletions .github/workflows/update-issue-status.yml
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"

0 comments on commit d5d7de3

Please sign in to comment.