1
0
mirror of synced 2026-01-06 06:02:35 -05:00

Update workflows to support all future issues being in Docs Engineering and Docs Content (#19689)

Add automation to support new repo recommendations.

Co-authored-by: chiedo <chiedo@users.noreply.github.com>
Co-authored-by: James M. Greene <JamesMGreene@github.com>
This commit is contained in:
Chiedo John
2021-06-07 15:41:48 -04:00
committed by GitHub
parent bdf34c904c
commit 3487088bc9
7 changed files with 166 additions and 183 deletions

View File

@@ -21,6 +21,8 @@ jobs:
steps:
- id: membership_check
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
env:
TEAM_CONTENT_REPO: ${{ secrets.TEAM_CONTENT_REPO }}
with:
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
script: |
@@ -59,7 +61,7 @@ jobs:
// Create an issue in our private repo
await github.issues.create({
owner: 'github',
repo: 'docs-internal',
repo: process.env.TEAM_CONTENT_REPO,
title: `@${context.payload.sender.login} confirm that \#${issueNo} should be in the public github/docs repo`,
body: `@${context.payload.sender.login} opened https://github.com/github/docs/issues/${issueNo} publicly in the github/docs repo, instead of the private github/docs-internal repo.\n\n@${context.payload.sender.login}, please confirm that this belongs in the public repo and that no sensitive information was disclosed by commenting below and closing the issue.\n\nIf this was not intentional and sensitive information was shared, please delete https://github.com/github/docs/issues/${issueNo} and notify us in the \#docs-open-source channel.\n\nThanks!`,
labels: ['OS confirmation'],

View File

@@ -0,0 +1,77 @@
name: Move existing issues to correct docs repo
# **What it does**: Move all existing issues to the correct repo
# **Why we have it**: We don't want engineering or content issues in the docs-internal repo
# **Who does it impact**: GitHub staff.
on:
workflow_dispatch:
jobs:
transfer_issues:
runs-on: ubuntu-latest
steps:
- id: move_to_correct_repo
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
env:
TEAM_ENGINEERING_REPO: ${{ secrets.TEAM_ENGINEERING_REPO }}
TEAM_CONTENT_REPO: ${{ secrets.TEAM_CONTENT_REPO }}
with:
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
script: |
const owner = 'github'
const originalRepo = 'docs-internal'
correctRepo = process.env.TEAM_ENGINEERING_REPO
let correctRepo;
const correctRepoObject = await github.repos.get({
owner: owner,
repo: correctRepo
})
const allIssues = await github.paginate(github.issues.listForRepo, {
owner: owner,
repo: originalRepo,
per_page: 100,
labels: ['engineering']
})
for (const issue of allIssues) {
// Extra redundancy with this additional check to be safe
if (issue.labels.find(label => label.name === 'engineering')) {
// Transfer the issue to the correct repo
const issueNodeId = issue.node_id
const correctRepositoryNodeId = correctRepoObject.data.node_id
console.log(`Issue GraphQL Node ID: ${issueNodeId}`)
console.log(`Repository GraphQL Node ID: ${correctRepositoryNodeId}`)
const mutation = `mutation ($id: ID!, $repositoryId: ID!) {
transferIssue(input: {
issueId: $id,
repositoryId: $repositoryId
}) {
issue {
url,
number
}
}
}`
const variables = {
id: issueNodeId,
repositoryId: correctRepositoryNodeId
}
const graph = await github.graphql(mutation, variables)
console.log('GraphQL mutation result:\n' + JSON.stringify(graph))
// Add the same labels to the new issue
const newIssueNumber = graph.transferIssue.issue.number
await github.issues.addLabels({
owner: owner,
repo: correctRepo,
issue_number: newIssueNumber,
labels: issue.labels.map(label => label.name),
})
}
}

View File

@@ -0,0 +1,86 @@
name: Move new issues to correct docs repo
# **What it does**: If anyone creates an issue in the docs-internal repo for the engineering team or the content team, move that issue and notify the author
# **Why we have it**: We don't want engineering or content issues in the docs-internal repo
# **Who does it impact**: GitHub staff.
on:
issues:
types:
- opened
- transferred
jobs:
transfer_issue:
runs-on: ubuntu-latest
continue-on-error: true
if: github.repository == 'github/docs-internal'
steps:
- id: move_to_correct_repo
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
env:
TEAM_ENGINEERING_REPO: ${{ secrets.TEAM_ENGINEERING_REPO }}
TEAM_CONTENT_REPO: ${{ secrets.TEAM_CONTENT_REPO }}
with:
github-token: ${{ secrets.DOCUBOT_FR_PROJECT_BOARD_WORKFLOWS_REPO_ORG_READ_SCOPES }}
script: |
const issueNo = context.issue.number
const owner = 'github'
const originalRepo = 'docs-internal'
// See if the engineering label is present.
const engineeringLabel = context.payload.issue.labels.find(label => label.name === 'engineering')
// Transfer engineering issues to the engineering repo and everything else to the Docs Content repo
let correctRepo = process.env.TEAM_CONTENT_REPO
if (engineeringLabel) {
correctRepo = process.env.TEAM_ENGINEERING_REPO
}
const correctRepoObject = await github.repos.get({
owner: owner,
repo: correctRepo
})
// Post a comment in the docs-internal issue
await github.issues.createComment({
owner: owner,
repo: originalRepo,
issue_number: issueNo,
body: `👋 Moving forward, we're asking that folks create all new Docs issues in the [${process.env.TEAM_ENGINEERING_REPO}](${process.env.TEAM_ENGINEERING_REPO}) repo and all new content issues in [${process.env.TEAM_CONTENT_REPO}](${process.env.TEAM_CONTENT_REPO}). We transferred it for you!`
})
// Transfer the issue to the correct repo
const issueNodeId = context.payload.issue.node_id
const correctRepositoryNodeId = correctRepoObject.data.node_id
console.log(`Issue GraphQL Node ID: ${issueNodeId}`)
console.log(`Repository GraphQL Node ID: ${correctRepositoryNodeId}`)
const mutation = `mutation ($id: ID!, $repositoryId: ID!) {
transferIssue(input: {
issueId: $id,
repositoryId: $repositoryId
}) {
issue {
url,
number
}
}
}`
const variables = {
id: issueNodeId,
repositoryId: correctRepositoryNodeId
}
const graph = await github.graphql(mutation, variables)
console.log('GraphQL mutation result:\n' + JSON.stringify(graph))
// Add the same labels to the new issue
const newIssueNumber = graph.transferIssue.issue.number
await github.issues.addLabels({
owner: owner,
repo: correctRepo,
issue_number: newIssueNumber,
labels: context.payload.issue.labels.map(label => label.name),
})

View File

@@ -1,63 +0,0 @@
name: Send Issue to How We Work Boards
# **What it does**:
# **Why we have it**:
# **Who does it impact**:
on:
issues:
types:
- labeled
- opened
- reopened
jobs:
triage:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- if: (github.repository == 'github/docs-internal') && contains(github.event.issue.labels.*.name, 'engineering') && !contains(github.event.issue.labels.*.name, 'no-hww-board') && !contains(github.event.issue.labels.*.name, 'batch') && !contains(github.event.issue.labels.*.name, 'epic')
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
var column_id = 9659080;
try {
github.projects.createCard({
column_id: column_id,
content_id: context.payload.issue.id,
content_type: "Issue"
});
} catch (error) {
console.log(error);
}
- if: (github.repository == 'github/docs-internal') && contains(github.event.issue.labels.*.name, 'engineering') && !contains(github.event.issue.labels.*.name, 'no-hww-board') && contains(github.event.issue.labels.*.name, 'batch')
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
var column_id = 13445681;
try {
github.projects.createCard({
column_id: column_id,
content_id: context.payload.issue.id,
content_type: "Issue"
});
} catch (error) {
console.log(error);
}
- if: (github.repository == 'github/docs-internal') && contains(github.event.issue.labels.*.name, 'engineering') && !contains(github.event.issue.labels.*.name, 'no-hww-board') && contains(github.event.issue.labels.*.name, 'epic')
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
var column_id = 12860544;
try {
github.projects.createCard({
column_id: column_id,
content_id: context.payload.issue.id,
content_type: "Issue"
});
} catch (error) {
console.log(error);
}

View File

@@ -1,49 +0,0 @@
name: Send pull_request to How We Work Boards
# **What it does**: This sends pull requests with the feature label to the Docs Engineering feature board
# **Why we have it**: If we use PRs to track features this automates them ending up on the feature board
# **Who does it impact**: Docs Engineering team members
on:
pull_request:
types:
- labeled
- opened
- reopened
jobs:
triage:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- if: (github.repository == 'github/docs-internal') && !contains(github.event.issue.labels.*.name, 'no-hww-board') && contains(github.event.pull_request.labels.*.name, 'batch')
uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
// Only do this for work by the engineering folks since multiple teams do work
// in the docs repos
try {
await github.teams.getMembershipForUserInOrg({
org: 'github',
team_slug: 'docs-engineering',
username: context.payload.sender.login,
});
} catch(err) {
return
}
var column_id = 13445681;
try {
await github.projects.createCard({
column_id: column_id,
content_id: context.payload.pull_request.id,
content_type: "PullRequest"
});
} catch (error) {
if (error.includes('Project already has the associated issue')) {
return
} else {
console.log(error);
}
}

View File

@@ -1,46 +0,0 @@
name: Automatically Keep Epic Status Labels Updated
on:
issue_comment:
types: [created, edited]
jobs:
post-status-updates-to-slack:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '_created with') && contains(github.event.comment.body, 'typing_ `/status`')
steps:
- uses: actions/github-script@626af12fe9a53dc2972b48385e7fe7dec79145c9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = context.payload.issue
const owner = context.repo.owner
const repo = context.payload.repository.name
const allStatusLabels = [
'green',
'grey',
'yellow',
'black',
'red'
];
const currentLabels = await github.issues.listLabelsOnIssue({
owner: owner,
repo: repo,
issue_number: issue.number
});
const newLabels = currentLabels.data.filter( label => allStatusLabels.includes(label.name) === false)
allStatusLabels.forEach( label => {
if(context.payload.comment.body.toLowerCase().includes(`status: ${label}`)) {
newLabels.push(label)
}
});
await github.issues.update({
owner: owner,
repo: repo,
issue_number: issue.number,
labels: newLabels,
});