Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Closed
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
32 changes: 32 additions & 0 deletions .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,39 @@ workflow "GraphQL schema update" {
resolves = "Update schema"
}

workflow "Core team issues" {
on = "issues"
resolves = "Add issue to release board"
}

workflow "Core team pull requests" {
on = "pull_request"
resolves = "Add pull request to release board"
}

action "Update schema" {
uses = "./actions/schema-up"
secrets = ["GITHUB_TOKEN"]
}

action "Consider issue for release board" {
uses = "actions/bin/filter@master"
args = "action assigned"
}

action "Add issue to release board" {
needs = "Consider issue for release board"
uses = "./actions/auto-sprint"
secrets = ["GITHUB_TOKEN"]
}

action "Consider pull request for release board" {
uses = "actions/bin/filter@master"
args = "action 'opened|merged|assigned|reopened'"
}

action "Add pull request to release board" {
needs = "Consider pull request for release board"
uses = "./actions/auto-sprint"
secrets = ["GRAPHQL_TOKEN"]
}
18 changes: 18 additions & 0 deletions actions/auto-sprint/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM node:8-slim

LABEL "com.github.actions.name"="auto-sprint"
LABEL "com.github.actions.description"="Add opened pull requests and assigned issues to the current sprint project"
LABEL "com.github.actions.icon"="list"
LABEL "com.github.actions.color"="white"

# Copy the package.json and package-lock.json
COPY package*.json ./

# Install dependencies
RUN npm ci

# Copy the rest of your action's code
COPY . /

# Run `node /index.js`
ENTRYPOINT ["node", "/index.js"]
84 changes: 84 additions & 0 deletions actions/auto-sprint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
const {Toolkit} = require('actions-toolkit');
const {withDefaults} = require('actions-toolkit/lib/graphql');

Toolkit.run(async tools => {
// Re-authenticate with the correct secret.
tools.github.graphql = withDefaults(process.env.GRAPHQL_TOKEN);

// Ensure that the actor of the triggering action belongs to the core team
const actorLogin = tools.context.actor;
const teamResponse = await tools.github.graphql(`
query {
organization(login: "atom") {
team(slug: "github-package") {
members(first: 100) {
nodes {
login
}
}
}
}
}
`);
if (!teamResponse.organization.team.members.nodes.some(node => node.login === actorLogin)) {
tools.exit.neutral('User %s is not in the github-package team. Thanks for your contribution!', actorLogin);
}

// Identify the active release board and its "In progress" column
const projectQuery = await tools.github.graphql(`
query {
repository(owner: "atom", name: "github") {
projects(
search: "Release"
states: [OPEN]
first: 1
orderBy: {field: CREATED_AT, direction: DESC}
) {
nodes {
id
name

columns(first: 10) {
nodes {
id
name
}
}
}
}
}
}
`);
const project = projectQuery.repository.projects.nodes[0];
if (!project) {
tools.exit.failure('No open project found with a name matching "Release".');
}
const column = project.columns.nodes.find(node => node.name === 'In progress');
if (!column) {
tools.exit.failure('No column found in the project %s with a name of exactly "In progress".', project.name);
}

// Add the issue/pull request to the sprint board
await tools.github.graphql(`
mutation ProjectCardAddition($columnID: ID!, $issueishID: ID!) {
addProjectCard(input: {projectColumnId: $columnID, contentId: $issueishID}) {
clientMutationId
}
}
`, {
columnID: column.id,
issueishID: tools.context.event === 'issues'
? tools.context.payload.issue.node_id
: tools.context.payload.pull_request.node_id,
});
tools.exit.success('Added as a project card.');
}, {
event: [
'issues.assigned',
'pull_request.opened',
'pull_request.merged',
'pull_request.assigned',
'pull_request.reopened',
],
secrets: ['GRAPHQL_TOKEN'],
});
Loading