From 68ec3aa74f41ea636f9165e113ea33a6c25bd41d Mon Sep 17 00:00:00 2001 From: Cynthia Rich Date: Thu, 9 Apr 2020 12:22:12 -0400 Subject: [PATCH 1/7] change action_id to store --- config.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/config.yml b/config.yml index a72b703..e405417 100644 --- a/config.yml +++ b/config.yml @@ -11,43 +11,49 @@ before: - type: createIssue title: Planning the upload to GitHub body: 00_make-a-plan.md + store: + first_issue_url: '{{ result.data.html_url }}' steps: #1 - title: Plan the upload description: Explore your options for making the move to GitHub. event: issues.closed - link: '{{ repoUrl }}/issues/1' + link: '{{ store.first_issue_url }}' actions: - type: createIssue action_id: new_issue title: Preparing the project for Git body: 01_prepare.md + store: + second_issue_url: '{{ result.data.html_url }}' - type: respond with: 01_next.md data: - issueURL: '%actions.new_issue.data.html_url%' + issueURL: '{{ store.second_issue_url }}' #2 - title: Prepare the project description: Prepare your project for a happy life on GitHub. event: issues.closed - link: '{{ repoUrl }}/issues' + link: '{{ store.second_issue_url }}' actions: - type: createIssue title: Uploading your project body: 02_move-local.md + store: + third_issue_url: '{{ results.data.html_url }}' action_id: new_issue - type: respond with: 01_next.md data: - issueURL: '%actions.new_issue.data.html_url%' + issueURL: '{{ store.third_issue_url }}' #3 - title: Begin the upload description: Publish your project on GitHub. event: push - link: '{{ repoUrl }}/issues' + link: '{{ store.third_issue_url }}' actions: - type: getTree action_id: tree @@ -64,6 +70,8 @@ steps: action_id: new_issue title: Public or private repository? body: 03_confirm-visibility.md + store: + fourth_issue_url: {{ results.data.html_url }} data: private: '%payload.repository.private%' - type: closeIssue @@ -72,18 +80,20 @@ steps: with: 03_move-done-local.md issue: Uploading your project data: - issueURL: '%actions.new_issue.data.html_url%' + issueURL: '{{ store.fourth_issue_url }}' #4 - title: Public or private repository? description: Understand the difference between a public and private repository. event: issues.closed - link: '{{ repoUrl }}/issues' + link: '{{ store.fourth_issue_url }}' actions: - type: createIssue action_id: new_issue title: A few parting words body: 04_graceful-exit.md + store: + fifth_issue_url: {{ results.data.html_url }} - type: respond with: 01_next.md data: - issueURL: '%actions.new_issue.data.html_url%' + issueURL: '{{ store.fifth_issue_url }}' From eda10bbccac39e0f428b78e34891e945890b1428 Mon Sep 17 00:00:00 2001 From: Cynthia Rich Date: Thu, 9 Apr 2020 12:24:17 -0400 Subject: [PATCH 2/7] remove legacy index.js file --- index.js | 328 ------------------------------------------------------- 1 file changed, 328 deletions(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index d1087c0..0000000 --- a/index.js +++ /dev/null @@ -1,328 +0,0 @@ -module.exports = course => { - course.before(async context => { - await context.github.issues.createLabel(context.repo({ - name: 'migration', - color: '5319e7' - })) - - await context.github.issues.createLabel(context.repo({ - name: 'local', - color: 'ed8285' - })) - - await context.github.issues.createLabel(context.repo({ - name: 'other', - color: '93edb1' - })) - - return context.newIssue({ - title: 'Planning the move to GitHub', - body: context.fromFile('01_make-a-plan.md') - }) - }) - - course.on('plan-the-move', async context => { - if (context.payload.issue.title !== 'Planning the move to GitHub' && (context.payload.action === 'closed' || context.payload.action === 'labeled')) { - await context.respond(context.fromFile('e_generic.md')) - return false - } - - if (context.payload.action === 'closed') { - const otherLabel = context.payload.issue.labels.find(label => label.name === 'other') - - if (otherLabel || !context.payload.issue.labels.length) { - await context.github.issues.edit(context.repo({ - number: context.payload.issue.number, - labels: ['local'] - })) - - if (!context.payload.issue.labels.length) await context.respond(context.fromFile('03_need-labels.md')) - } - - const prepareIssue = await context.newIssue({ - title: 'Preparing the project for Git', - body: context.fromFile(`04_prepare.md`) - }) - - course.log(`created a new issue at ${prepareIssue.html_url}`) - - return context.respond(context.fromFile(`02_next.md`, { issueURL: prepareIssue.html_url })) - } else if (context.payload.action === 'labeled') { - // if label is `migration` - course.log(`a label was added`) - if (context.payload.label.name === 'migration') { - course.log(`migration added`) - await context.respond(context.fromFile(`02_make-a-plan-vcs.md`)) - } - // comment: 02_make-a-plan-vcs.md - // if label is `local` - if (context.payload.label.name === 'local') { - course.log(`local added`) - await context.respond(context.fromFile(`02_make-a-plan-local.md`)) - } - // comment: 02_make-a-plan-local.md - // if label is `other` - if (context.payload.label.name === 'other') { - course.log(`other added`) - await context.respond(context.fromFile(`02_make-a-plan-other.md`)) - } - } - return false - }) - - course.on('prepare-the-project', async context => { - // TODO abstract relevant issue/pr titles into app steps - /* in the config, we should be able to specify a specific issue/pr - * title that will link the step and the issue/pr. Therefore, the step - * will only be triggered when the event comes from that particular - * issue/pr. - * - * 👇 should replace this kind of check - */ - if (context.payload.issue.title !== 'Preparing the project for Git') { - await context.respond(context.fromFile('e_generic.md')) - return false - } - - const issues = await context.github.issues.getForRepo(context.repo({ - state: 'all' - })) - const firstIssue = issues.data.find(issue => issue.title === 'Planning the move to GitHub') - - course.log(`looking for first issue, number: ${firstIssue.number}`) - - if (firstIssue) { - course.log(`the labels: ${JSON.stringify(firstIssue.labels)}`) - - const localLabel = firstIssue.labels.find(label => label.name === 'local') - const migrationLabel = firstIssue.labels.find(label => label.name === 'migration') - - if (localLabel) { - course.log(`Found a local label`) - const moveLocalIssue = await context.newIssue({ - title: 'Publishing your local project', - body: context.fromFile(`05_move-local.md`, {url: `https://github.com/${context.user.username}/${context.payload.repository.name}.git`}) - }) - - await context.respond(context.fromFile(`04_next.md`, { issueURL: moveLocalIssue.html_url })) - - if (migrationLabel) { - await context.github.issues.createComment(context.repo({ - number: moveLocalIssue.number, - body: context.fromFile(`05_move-both.md`) - })) - - await context.github.issues.createComment(context.repo({ - number: moveLocalIssue.number, - body: context.fromFile(`05_move-import.md`) - })) - } - return true - } else if (migrationLabel) { - course.log(`Found a migration label`) - const importIssue = await context.newIssue({ - title: 'Importing your project', - body: context.fromFile(`05_move-import.md`) - }) - - return context.respond(context.fromFile(`04_next.md`, { issueURL: importIssue.html_url })) - } - } - - return false - // if `local` label was on original issue - // new issue: title; "Publishing your Local Project", content; 05_move-local.md - // if `migration` label was on original issue - // new issue: title; "Importing your Project", content: 05_move-import.md - // if `local` & `migration` - // new issue: title; "Publishing your Project", content; 05_move-both.md - // comment in issue: 05_move-import.md - }) - - course.on('make-the-move', async context => { - course.log(`Looking for a .gitignore`) - - const issues = await context.github.issues.getForRepo(context.repo({ - state: 'all' - })) - - let publishIssue - - if (!(publishIssue = issues.data.find(issue => issue.title === 'Importing your project'))) publishIssue = issues.data.find(issue => issue.title === 'Publishing your local project') - - try { - await context.github.repos.getContent(context.repo({ - path: '.gitignore' - })) - } catch (e) { - if (e.code === 404) { - // respond by saying that gitignore isn't found - course.log('No .gitignore') - - await context.github.issues.createComment(context.repo({ - number: publishIssue.number, - body: context.fromFile('e_needs_gitignore.md') - })) - } else { - course.log(`Got some error: ${e}`) - return false - } - } - - let communityProfile - if (!context.payload.repository.private) { - communityProfile = await context.github.repos.getCommunityProfileMetrics({ - owner: context.repo().owner, - name: context.repo().repo - }) - } - - const tree = (await context.github.gitdata.getTree(context.repo({ sha: context.payload.head_commit.id }))).data.tree - - const communityMilestone = await context.github.issues.createMilestone(context.repo({ - title: 'Community check' - })) - - let communityIssue - if (communityProfile) { - communityIssue = await context.newIssue(context.repo({ - title: 'About your community score', - body: context.fromFile('about-community.md', { - health_percentage: communityProfile.data.health_percentage, - community_url: `https://github.com/${context.user.username}/${context.payload.repository.name}/community`, - milestoneURL: communityMilestone.data.html_url - }) - })) - } else { - communityIssue = await context.newIssue(context.repo({ - title: 'About your community score', - body: context.fromFile('making-collaboration-easier.md', {milestoneURL: communityMilestone.data.html_url}) - })) - } - - if (!context.payload.repository.description) { - await context.newIssue(context.repo({ - title: 'Add a repository description', - body: context.fromFile('08_collabs-description-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - if (!tree.some(f => f.path === 'README.md')) { - await context.newIssue(context.repo({ - title: 'Add a README', - body: context.fromFile('08_collabs-README-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - if (!tree.some(f => f.path.includes('CODE_OF_CONDUCT.md'))) { - await context.newIssue(context.repo({ - title: 'Add a Code of Conduct', - body: context.fromFile('08_collabs-code-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - if (!tree.some(f => f.path.includes('CONTRIBUTING.md'))) { - await context.newIssue(context.repo({ - title: 'Add a contributing guide', - body: context.fromFile('08_collabs-contributing-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - if (!tree.some(f => f.path.includes('LICENSE'))) { - await context.newIssue(context.repo({ - title: 'Add a license', - body: context.fromFile('08_collabs-license-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - if (!tree.some(f => f.path.includes('ISSUE_TEMPLATE.md')) && !tree.some(f => f.path.includes('PULL_REQUEST_TEMPLATE.md'))) { - await context.newIssue(context.repo({ - title: 'Add an issue or PR template', - body: context.fromFile('08_collabs-templates-new.md', { private: context.payload.repository.private }), - milestone: communityMilestone.data.number - })) - } - - await context.github.issues.edit(context.repo({ - number: publishIssue.number, - state: 'closed' - })) - - return context.github.issues.createComment(context.repo({ - number: publishIssue.number, - body: context.fromFile(`06_move-done-local.md`, {url: communityIssue.html_url}) - })) - }) - - course.on('prepare-to-collaborate', async context => { - if (context.payload.issue.title !== 'About your community score') return false - - const settingsMilestone = await context.github.issues.createMilestone(context.repo({ - title: 'Project settings check' - })) - - const settingsIssue = await context.newIssue(context.repo({ - title: 'Your repository settings', - body: context.fromFile('07_settings.md', context.repo({milestoneURL: settingsMilestone.data.html_url})) - })) - - await context.newIssue(context.repo({ - title: 'Confirm your repository visibility', - body: context.fromFile('07_confirm-visibility.md', {visibility: (context.payload.repository.private ? 'private' : 'public')}), - milestone: settingsMilestone.data.number - })) - - await context.newIssue(context.repo({ - title: 'Invite collaborators', - body: context.fromFile('07_invite-collaborators.md', context.repo()), - milestone: settingsMilestone.data.number - })) - - await context.newIssue(context.repo({ - title: 'Set up protected branches', - body: context.fromFile('07_protected-branches.md', context.repo()), - milestone: settingsMilestone.data.number - })) - - await context.newIssue(context.repo({ - title: 'Set up integrations', - body: context.fromFile('07_integrations.md'), - milestone: settingsMilestone.data.number - })) - - return context.respond(context.fromFile('02_next.md', {issueURL: settingsIssue.html_url})) - }) - - course.on('project-settings', async context => { - if (context.payload.issue.title !== 'Your repository settings') return false - - const docIssue = await context.newIssue(context.repo({ - title: 'Add documentation', - body: context.fromFile('10_users-documentation.md', context.repo()) - })) - - const releaseIssue = await context.newIssue(context.repo({ - title: 'Release your software', - body: context.fromFile('11_users-releases.md') - })) - - const goodbyeIssue = await context.newIssue(context.repo({ - title: 'A few parting words', - body: context.fromFile('12_graceful-exit.md', {issue1: docIssue.html_url, issue2: releaseIssue.html_url}) - })) - - return context.respond(context.fromFile('02_next.md', {issueURL: goodbyeIssue.html_url})) - }) - - // course.on('document-your-project', async context => { - // // create new issue: title; "Adding Documentation to your project", body; 10_users-documentation.md - // }) - // course.on('release-your-software', async context => { - // // new issue: title; "Creating your first release", body; 11_users-releases.md - // }) -} From ae3856e69af80705b0656da37021fdb68bc7cb75 Mon Sep 17 00:00:00 2001 From: Cynthia Rich Date: Thu, 9 Apr 2020 12:31:31 -0400 Subject: [PATCH 3/7] a few more action_ids --- config.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/config.yml b/config.yml index e405417..58905ad 100644 --- a/config.yml +++ b/config.yml @@ -22,7 +22,6 @@ steps: link: '{{ store.first_issue_url }}' actions: - type: createIssue - action_id: new_issue title: Preparing the project for Git body: 01_prepare.md store: @@ -43,7 +42,6 @@ steps: body: 02_move-local.md store: third_issue_url: '{{ results.data.html_url }}' - action_id: new_issue - type: respond with: 01_next.md data: @@ -56,10 +54,11 @@ steps: link: '{{ store.third_issue_url }}' actions: - type: getTree - action_id: tree + store: + repo_tree: '{{ tree }}' - type: gate required: false - left: '%actions.tree.data.tree%' + left: '{{ store.repo_tree }}' operator: includes right: path:.gitignore else: @@ -67,7 +66,6 @@ steps: issue: Uploading your project with: e_needs_gitignore.md - type: createIssue - action_id: new_issue title: Public or private repository? body: 03_confirm-visibility.md store: @@ -88,7 +86,6 @@ steps: link: '{{ store.fourth_issue_url }}' actions: - type: createIssue - action_id: new_issue title: A few parting words body: 04_graceful-exit.md store: From 28fcbd9c0c956ced10e6310cd4a139852fc03454 Mon Sep 17 00:00:00 2001 From: Cynthia Rich Date: Thu, 9 Apr 2020 12:35:31 -0400 Subject: [PATCH 4/7] move one more action --- config.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config.yml b/config.yml index 58905ad..da7fb91 100644 --- a/config.yml +++ b/config.yml @@ -69,9 +69,10 @@ steps: title: Public or private repository? body: 03_confirm-visibility.md store: - fourth_issue_url: {{ results.data.html_url }} + fourth_issue_url: '{{ results.data.html_url }}' + repo_visibility: '{{ payload.repository.private }}' data: - private: '%payload.repository.private%' + private: '{{ store.repo_visibility }}' - type: closeIssue issue: Uploading your project - type: respond @@ -89,7 +90,7 @@ steps: title: A few parting words body: 04_graceful-exit.md store: - fifth_issue_url: {{ results.data.html_url }} + fifth_issue_url: '{{ results.data.html_url }}' - type: respond with: 01_next.md data: From 9562f729201363c838b7563300cba96455322ab8 Mon Sep 17 00:00:00 2001 From: Cynthia Rich Date: Thu, 9 Apr 2020 13:01:33 -0400 Subject: [PATCH 5/7] don't use tree in store and just pass data --- config.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/config.yml b/config.yml index da7fb91..02c72f3 100644 --- a/config.yml +++ b/config.yml @@ -54,11 +54,10 @@ steps: link: '{{ store.third_issue_url }}' actions: - type: getTree - store: - repo_tree: '{{ tree }}' + action_id: tree - type: gate required: false - left: '{{ store.repo_tree }}' + left: '{{ actions.tree.data.tree }}' operator: includes right: path:.gitignore else: @@ -70,9 +69,8 @@ steps: body: 03_confirm-visibility.md store: fourth_issue_url: '{{ results.data.html_url }}' - repo_visibility: '{{ payload.repository.private }}' data: - private: '{{ store.repo_visibility }}' + private: '{{ payload.repository.private }}' - type: closeIssue issue: Uploading your project - type: respond From 2e6a793ea7f331036c2380020e7936455375bf08 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Wed, 22 Apr 2020 13:05:18 -0400 Subject: [PATCH 6/7] fix some typos --- config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.yml b/config.yml index 02c72f3..2ca89a2 100644 --- a/config.yml +++ b/config.yml @@ -41,7 +41,7 @@ steps: title: Uploading your project body: 02_move-local.md store: - third_issue_url: '{{ results.data.html_url }}' + third_issue_url: '{{ result.data.html_url }}' - type: respond with: 01_next.md data: @@ -68,7 +68,7 @@ steps: title: Public or private repository? body: 03_confirm-visibility.md store: - fourth_issue_url: '{{ results.data.html_url }}' + fourth_issue_url: '{{ result.data.html_url }}' data: private: '{{ payload.repository.private }}' - type: closeIssue @@ -88,7 +88,7 @@ steps: title: A few parting words body: 04_graceful-exit.md store: - fifth_issue_url: '{{ results.data.html_url }}' + fifth_issue_url: '{{ result.data.html_url }}' - type: respond with: 01_next.md data: From 2d702d8c3bd2ecb92c6ed36fe2b7c1addc245124 Mon Sep 17 00:00:00 2001 From: Hector Alfaro Date: Wed, 22 Apr 2020 13:08:16 -0400 Subject: [PATCH 7/7] auto-close based on number to avoid replication lag --- config.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 2ca89a2..d34ba39 100644 --- a/config.yml +++ b/config.yml @@ -42,6 +42,7 @@ steps: body: 02_move-local.md store: third_issue_url: '{{ result.data.html_url }}' + third_issue_number: '{{ result.data.number }}' - type: respond with: 01_next.md data: @@ -72,7 +73,8 @@ steps: data: private: '{{ payload.repository.private }}' - type: closeIssue - issue: Uploading your project + issue: '{{ store.third_issue_number }}' + required: false - type: respond with: 03_move-done-local.md issue: Uploading your project