| Sep | OCT | Nov |
| 27 | ||
| 2019 | 2020 | 2021 |
COLLECTED BY
Collection: Save Page Now
| Acourse on GitHub Learning Lab can guide you through this step. |
|---|
type: key followed by the name of the action. For example:
- type: respond
with: my-response.md
Whenever possible, actions will infer context from the event that triggered the step. Sometimes, actions have additional requirements that are listed in the action documentation.
For example:
●the respond action requires a with option pointing to the Markdown file containing the body of the response.
●the respond action allows the optional use of an issue option, allowing you to specify a specific issue or pull request in which to respond. If the issue or pull request isn't supplied, the action will try to respond based on the event that triggered it. If the event that triggered the action doesn't contain an issue or a pull request (for example, in the case of a page_build event), the action will fail and the step won't be completed.
data object. Within the data object, include a name and value for each variable you want to pass.
For example:
- title: Commit a file
description: Commit your file to the branch.
event: push
link: '{{ repoUrl }}/issues/2'
actions:
- type: respond
issue: Your first contribution
with: open-a-pr.md
# the data object
data:
# we're passing a variable called `branch`, it contains the ref from the payload
branch: '{{ payload.ref }}'
# we're passing a second variable called `url`, it contains the repository's URL concatenated with some additional text
url: '{{ payload.repository.html_url }}/compare/{{ payload.ref }}?expand=1'
This data will be accessible in the response file with {{ branch }} and {{ url }}.
action_id key to your action, as follows:
steps:
- title: Comment on this issue
event: issue_comment.created
actions:
- type: createIssue
title: New issue
body: an-issue.md
# Store the API response for this new issue by assigning it to an action_id
action_id: new_issue
To use the information from the action, use the '{{ actions }}' object and dot notation with the identifier for the action, as follows:
steps:
- title: Comment on this issue
event: issue_comment.created
actions:
- type: createIssue
title: New issue
body: an-issue.md
# Store the response for this new issue by assigning an action_id
action_id: new_issue
# Respond in the issue the user just commented on
- type: respond
with: a-response.md
# Include a `data` object to provide some template variables
data:
# Reference the response of the `new_issue` action
nextIssueUrl: '{{ actions.new_issue.data.html_url }}'
required option for that action.
Here's an example:
actions:
# get the contents of a file titled index.html, store them in an action identifier called `index_file`
- type: getFileContents
filename: index.html
action_id: index_file
# check if `index_file` contains an <html> tag, store the response in an action identifier called `contains_html`. If the action fails (because, say, no <html> tag exists), don't stop the course from executing. We'll use the information to provide the learner feedback
- type: htmlContainsTag
html: '{{ actions.index_file }}'
tag: html
action_id: contains_html
required: false
# Respond to the learner conditionally using `contains_html`.
- type: gate
left: '{{ actions.contains_html }}'
else:
type: createReview
body: 03e-add-html.md
event: REQUEST_CHANGES
- type: createReview
event: COMMENT
body: 03-title-tag.md
- type: createIssue
title: Creating this issue!
store:
first_issue_url: '{{ result.data.html_url }}'
first_issue_number: '{{ result.data.number }}'
Some important notes on what you can store:
●The information you can store is limited to strings, numbers, and booleans - so you cannot store an entire response object. If your use case requires the entire response object, use the action_id property.
●Attempting to store a key that already exists will throw an error and cause that step to fail. This is to avoid accidentally overwriting stored data.
In the store object, you'll have access to a special result object; this is the direct return value of the action. You can read through the actions' source code to see what those values are.
And then you can use it later on:
steps:
# In a step link
link: '{{ store.first_issue_url }}'
# Or in an action
actions:
- type: gate
left: '{{ store.first_issue_number }}'
operator: ===
right: '{{ payload.issue.number }}'
You can also use the store object from within a markdown response template:
Check out issue number [{{ store.first_issue_number }}]({{ store.first_issue_url }})!
github/learning-lab-components repository!
●© 2020 GitHub, Inc.
●Contact GitHub
●Blog
●About
●Community
●Help Center
●API
●Terms