Skip to content
This repository was archived by the owner on Sep 1, 2022. It is now read-only.

Commit c453271

Browse files
committed
adding more steps
1 parent cd05b9e commit c453271

File tree

4 files changed

+161
-36
lines changed

4 files changed

+161
-36
lines changed

config.yml

Lines changed: 90 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ steps:
8989
fileName: my-workflow.yml
9090
# End filepath verification
9191
#######################################################
92+
- type: removeBranchProtection
9293
- type: respond
9394
issue: Start here!
9495
with: new-pull-request.md
9596
data:
9697
pullUrl: "%payload.pull_request.html_url%"
9798
- type: closeIssue
9899
issue: Start here!
99-
- type: removeBranchProtection
100+
100101
- type: respond
101102
with: 01_merge-workflow.md
102103
data:
@@ -135,7 +136,7 @@ steps:
135136
debug: "%payload%"
136137
- type: respond
137138
with: 03_workflow-success.md
138-
issue: Create an issue comment with GitHub Script
139+
issue: 3
139140
- type: octokit
140141
method: projects.listForRepo
141142
owner: "%payload.repository.owner.login%"
@@ -152,4 +153,90 @@ steps:
152153
listProj: "%actions.projectBoard.data%"
153154
listCol: "%actions.listColumns.data%"
154155
columnID: "%actions.listColumns.data.0.id%"
155-
quicklink: "%payload.repository.html_url%/edit/master/.github/workflows/my-workflow.yml%"
156+
quicklink: "%payload.repository.html_url%/edit/master/.github/workflows/my-workflow.yml"
157+
# new pull request
158+
- title: Modify your workflow file
159+
description: Create a pull request to add changes to your workflow
160+
event: pull_request
161+
link: "{{ repoUrl }}/pull/4"
162+
actions:
163+
- type: gate
164+
gates:
165+
# if the payload action is 'opened' OR 'edited'
166+
- left: "%payload.action%"
167+
operator: ===
168+
right: opened
169+
- left: "%payload.action%"
170+
operator: ===
171+
right: edited
172+
# AND the pull request title equals 'Create my-workflow.yml'
173+
- type: gate
174+
left: "%payload.pull_request.title%"
175+
operator: ===
176+
right: Update my-workflow.yml
177+
178+
# if those statments FAIL... do this
179+
else:
180+
- type: respond
181+
with: e-rename-pr.md
182+
data:
183+
title: Update my-workflow.yml
184+
# if those gates === true Then do this stuff
185+
186+
#######################################################
187+
# Validate the filepath for the my-workflow.yml file
188+
# get tree
189+
- type: getTree
190+
action_id: isInTree
191+
recursive: true
192+
sha: "%payload.pull_request.head.sha%"
193+
# check for a file in a tree
194+
- type: gate
195+
left: "%actions.isInTree.data.tree%"
196+
operator: includes
197+
right: "path:.github/workflows/my-workflow.yml"
198+
else:
199+
# if file isn't where expected find true location
200+
- type: findInTree
201+
path: my-workflow.yml
202+
tree: "%actions.isInTree.data.tree%"
203+
# multiple: true
204+
action_id: fileLocation
205+
# help user with proper file location
206+
- type: respond
207+
with: e-wrong-file-location.md
208+
data:
209+
haveFile: "%actions.fileLocation.path%"
210+
needFile: ".github/actions/cat-facts/action.yml"
211+
editLink: "%payload.repository.html_url%/edit/%payload.pull_request.head.ref%/%actions.fileLocation.path%"
212+
fileName: my-workflow.yml
213+
# End filepath verification
214+
#######################################################
215+
- type: removeBranchProtection
216+
- type: respond
217+
issue: 3
218+
with: new-pull-request.md
219+
data:
220+
pullUrl: "%payload.pull_request.html_url%"
221+
- type: closeIssue
222+
issue: 3
223+
- type: respond
224+
with: 04_merge-workflow.md
225+
data:
226+
actionsUrl: "%payload.repository.html_url%/actions"
227+
228+
- title: Merge the new workflow into the master branch
229+
description: Make the workflow available for use on the repository
230+
event: pull_request.closed
231+
link: "{{ repoUrl }}/issues/5"
232+
actions:
233+
- type: updateBranchProtection
234+
- type: createIssue
235+
title: Create an issue comment with GitHub Script
236+
body: 05_workflow-triggered.md
237+
action_id: triggerIssue
238+
- type: respond
239+
with: new-issue.md
240+
issue: Update my-workflow.yml
241+
data:
242+
issueURL: "%actions.triggerIssue.data.html_url%"

responses/03_add-to-projects.md

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,53 @@
11
# let's add a card to a project board
22

3-
<!-- ## Project board
3+
We have added a project board to this repository for you. We will use this board, named **Learning Lab Project Board**, to add cards to when a new issue is created in your repository!
44

5-
{{listProj}}
5+
Like creating comments and opening pull requests, octokit/rest.js can be used for many more types of interactions. Managing GitHub Projects makes that list!
66

7-
## Column list
7+
<details><summary>Things aren't always as they appear!</summary>
8+
<br>
9+
Although this is not a course on octokit/rest.js, it is important to tell you a little secret right here before we move on. For you to be able to use the `projects.createCard()` method there were some pieces of information we needed beforehand. Things like the `column_id` so we know which column to add the card to and even a `project_id` so we know which board that column belongs to.
810

9-
{{listCol}} -->
11+
We've gone ahead and done this on our end of things so that we could give you the final piece to the puzzle and demonstrate how to use GitHub Script. So if you try to recreate this on your own, without the help of Learning Lab you will need to get that information and parse it in a way that works well for your use case!
12+
13+
</details>
1014

1115
### :keyboard: Activity: Add newly opened issue to project board
1216

13-
You can use [this link]({{quicklink}}) to easily edit this file.
14-
15-
```yaml
16-
name: Learning GitHub Script
17-
18-
on:
19-
issues:
20-
types: [opened]
21-
22-
jobs:
23-
comment:
24-
runs-on: ubuntu-latest
25-
steps:
26-
- uses: actions/github-script@0.8.0
27-
with:
28-
github-token: {% raw %}${{secrets.GITHUB_TOKEN}}{% endraw %}
29-
script: |
30-
github.issues.createComment({
31-
issue_number: context.issue.number,
32-
owner: context.repo.owner,
33-
repo: context.repo.repo,
34-
body: "🎉 You've created this issue comment using GitHub Script!!!"
35-
})
36-
github.projects.createCard({
37-
column_id: {{columnID}}
38-
content_id: context.payload.issue.id
39-
content_type: "Issue"
40-
});
41-
```
17+
1. [Edit]({{quicklink}}) the current workflow `.github/workflows/my-workflow.yml` to have he following contents:
18+
19+
```yaml
20+
name: Learning GitHub Script
21+
22+
on:
23+
issues:
24+
types: [opened]
25+
26+
jobs:
27+
comment:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/github-script@0.8.0
31+
with:
32+
github-token: {% raw %}${{secrets.GITHUB_TOKEN}}{% endraw %}
33+
script: |
34+
github.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: "🎉 You've created this issue comment using GitHub Script!!!"
39+
})
40+
github.projects.createCard({
41+
column_id: {{columnID}},
42+
content_id: context.payload.issue.id,
43+
content_type: "Issue"
44+
});
45+
```
46+
47+
2. Commit the workflow to a new branch.
48+
3. Create a pull request titled **Update my-workflow.yml**.
49+
4. Supply the pull request body content and click `Create pull request`.
50+
51+
---
52+
53+
I'll respond in the new pull request when I detect it has been created.

responses/04_merge-workflow.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## You have added a workflow!
2+
3+
@{{user.login}}, you're a rockstar ✨
4+
5+
You'r workflow now has the necessary updates for us to have new issues automatically added to the triage board when they are created!
6+
7+
Like before, this workflow has a trigger that pertains to the repository as a whole, rather than just this branch, we will need to merge this pull request before we can start using it.
8+
9+
Let's go ahead and do this now.
10+
11+
### :keyboard: Activity: Merge the workflow
12+
13+
When you are ready, merge this pull request.
14+
15+
---
16+
17+
Once you have merged this pull request I will open a new issue so we can see this workflow in action!
18+
19+
<details><summary>Trouble merging?</summary>Try refreshing the page!</details>

responses/05_workflow-triggered.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Great job @{{user.login}}
2+
3+
Now that your updates have been merged and we've triggered the workflow we should see our workflow begin helping us automate the triage of new issues.
4+
5+
---
6+
7+
I'll respond once your workflow has completed!

0 commit comments

Comments
 (0)