diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4ea99c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,395 @@ +Attribution 4.0 International + +======================================================================= + +Creative Commons Corporation ("Creative Commons") is not a law firm and +does not provide legal services or legal advice. Distribution of +Creative Commons public licenses does not create a lawyer-client or +other relationship. Creative Commons makes its licenses and related +information available on an "as-is" basis. Creative Commons gives no +warranties regarding its licenses, any material licensed under their +terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the +fullest extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and +conditions that creators and other rights holders may use to share +original works of authorship and other material subject to copyright +and certain other rights specified in the public license below. The +following considerations are for informational purposes only, are not +exhaustive, and do not form part of our licenses. + + Considerations for licensors: Our public licenses are + intended for use by those authorized to give the public + permission to use material in ways otherwise restricted by + copyright and certain other rights. Our licenses are + irrevocable. Licensors should read and understand the terms + and conditions of the license they choose before applying it. + Licensors should also secure all rights necessary before + applying our licenses so that the public can reuse the + material as expected. Licensors should clearly mark any + material not subject to the license. This includes other CC- + licensed material, or material used under an exception or + limitation to copyright. More considerations for licensors: + wiki.creativecommons.org/Considerations_for_licensors + + Considerations for the public: By using one of our public + licenses, a licensor grants the public permission to use the + licensed material under specified terms and conditions. If + the licensor's permission is not necessary for any reason--for + example, because of any applicable exception or limitation to + copyright--then that use is not regulated by the license. Our + licenses grant only permissions under copyright and certain + other rights that a licensor has authority to grant. Use of + the licensed material may still be restricted for other + reasons, including because others have copyright or other + rights in the material. A licensor may make special requests, + such as asking that all changes be marked or described. + Although not required by our licenses, you are encouraged to + respect those requests where reasonable. More considerations + for the public: + wiki.creativecommons.org/Considerations_for_licensees + +======================================================================= + +Creative Commons Attribution 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree +to be bound by the terms and conditions of this Creative Commons +Attribution 4.0 International Public License ("Public License"). To the +extent this Public License may be interpreted as a contract, You are +granted the Licensed Rights in consideration of Your acceptance of +these terms and conditions, and the Licensor grants You such rights in +consideration of benefits the Licensor receives from making the +Licensed Material available under these terms and conditions. + + +Section 1 -- Definitions. + + a. Adapted Material means material subject to Copyright and Similar + Rights that is derived from or based upon the Licensed Material + and in which the Licensed Material is translated, altered, + arranged, transformed, or otherwise modified in a manner requiring + permission under the Copyright and Similar Rights held by the + Licensor. For purposes of this Public License, where the Licensed + Material is a musical work, performance, or sound recording, + Adapted Material is always produced where the Licensed Material is + synched in timed relation with a moving image. + + b. Adapter's License means the license You apply to Your Copyright + and Similar Rights in Your contributions to Adapted Material in + accordance with the terms and conditions of this Public License. + + c. Copyright and Similar Rights means copyright and/or similar rights + closely related to copyright including, without limitation, + performance, broadcast, sound recording, and Sui Generis Database + Rights, without regard to how the rights are labeled or + categorized. For purposes of this Public License, the rights + specified in Section 2(b)(1)-(2) are not Copyright and Similar + Rights. + + d. Effective Technological Measures means those measures that, in the + absence of proper authority, may not be circumvented under laws + fulfilling obligations under Article 11 of the WIPO Copyright + Treaty adopted on December 20, 1996, and/or similar international + agreements. + + e. Exceptions and Limitations means fair use, fair dealing, and/or + any other exception or limitation to Copyright and Similar Rights + that applies to Your use of the Licensed Material. + + f. Licensed Material means the artistic or literary work, database, + or other material to which the Licensor applied this Public + License. + + g. Licensed Rights means the rights granted to You subject to the + terms and conditions of this Public License, which are limited to + all Copyright and Similar Rights that apply to Your use of the + Licensed Material and that the Licensor has authority to license. + + h. Licensor means the individual(s) or entity(ies) granting rights + under this Public License. + + i. Share means to provide material to the public by any means or + process that requires permission under the Licensed Rights, such + as reproduction, public display, public performance, distribution, + dissemination, communication, or importation, and to make material + available to the public including in ways that members of the + public may access the material from a place and at a time + individually chosen by them. + + j. Sui Generis Database Rights means rights other than copyright + resulting from Directive 96/9/EC of the European Parliament and of + the Council of 11 March 1996 on the legal protection of databases, + as amended and/or succeeded, as well as other essentially + equivalent rights anywhere in the world. + + k. You means the individual or entity exercising the Licensed Rights + under this Public License. Your has a corresponding meaning. + + +Section 2 -- Scope. + + a. License grant. + + 1. Subject to the terms and conditions of this Public License, + the Licensor hereby grants You a worldwide, royalty-free, + non-sublicensable, non-exclusive, irrevocable license to + exercise the Licensed Rights in the Licensed Material to: + + a. reproduce and Share the Licensed Material, in whole or + in part; and + + b. produce, reproduce, and Share Adapted Material. + + 2. Exceptions and Limitations. For the avoidance of doubt, where + Exceptions and Limitations apply to Your use, this Public + License does not apply, and You do not need to comply with + its terms and conditions. + + 3. Term. The term of this Public License is specified in Section + 6(a). + + 4. Media and formats; technical modifications allowed. The + Licensor authorizes You to exercise the Licensed Rights in + all media and formats whether now known or hereafter created, + and to make technical modifications necessary to do so. The + Licensor waives and/or agrees not to assert any right or + authority to forbid You from making technical modifications + necessary to exercise the Licensed Rights, including + technical modifications necessary to circumvent Effective + Technological Measures. For purposes of this Public License, + simply making modifications authorized by this Section 2(a) + (4) never produces Adapted Material. + + 5. Downstream recipients. + + a. Offer from the Licensor -- Licensed Material. Every + recipient of the Licensed Material automatically + receives an offer from the Licensor to exercise the + Licensed Rights under the terms and conditions of this + Public License. + + b. No downstream restrictions. You may not offer or impose + any additional or different terms or conditions on, or + apply any Effective Technological Measures to, the + Licensed Material if doing so restricts exercise of the + Licensed Rights by any recipient of the Licensed + Material. + + 6. No endorsement. Nothing in this Public License constitutes or + may be construed as permission to assert or imply that You + are, or that Your use of the Licensed Material is, connected + with, or sponsored, endorsed, or granted official status by, + the Licensor or others designated to receive attribution as + provided in Section 3(a)(1)(A)(i). + + b. Other rights. + + 1. Moral rights, such as the right of integrity, are not + licensed under this Public License, nor are publicity, + privacy, and/or other similar personality rights; however, to + the extent possible, the Licensor waives and/or agrees not to + assert any such rights held by the Licensor to the limited + extent necessary to allow You to exercise the Licensed + Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this + Public License. + + 3. To the extent possible, the Licensor waives any right to + collect royalties from You for the exercise of the Licensed + Rights, whether directly or through a collecting society + under any voluntary or waivable statutory or compulsory + licensing scheme. In all other cases the Licensor expressly + reserves any right to collect such royalties. + + +Section 3 -- License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the +following conditions. + + a. Attribution. + + 1. If You Share the Licensed Material (including in modified + form), You must: + + a. retain the following if it is supplied by the Licensor + with the Licensed Material: + + i. identification of the creator(s) of the Licensed + Material and any others designated to receive + attribution, in any reasonable manner requested by + the Licensor (including by pseudonym if + designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of + warranties; + + v. a URI or hyperlink to the Licensed Material to the + extent reasonably practicable; + + b. indicate if You modified the Licensed Material and + retain an indication of any previous modifications; and + + c. indicate the Licensed Material is licensed under this + Public License, and include the text of, or the URI or + hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any + reasonable manner based on the medium, means, and context in + which You Share the Licensed Material. For example, it may be + reasonable to satisfy the conditions by providing a URI or + hyperlink to a resource that includes the required + information. + + 3. If requested by the Licensor, You must remove any of the + information required by Section 3(a)(1)(A) to the extent + reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's + License You apply must not prevent recipients of the Adapted + Material from complying with this Public License. + + +Section 4 -- Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that +apply to Your use of the Licensed Material: + + a. for the avoidance of doubt, Section 2(a)(1) grants You the right + to extract, reuse, reproduce, and Share all or a substantial + portion of the contents of the database; + + b. if You include all or a substantial portion of the database + contents in a database in which You have Sui Generis Database + Rights, then the database in which You have Sui Generis Database + Rights (but not its individual contents) is Adapted Material; and + + c. You must comply with the conditions in Section 3(a) if You Share + all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not +replace Your obligations under this Public License where the Licensed +Rights include other Copyright and Similar Rights. + + +Section 5 -- Disclaimer of Warranties and Limitation of Liability. + + a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE + EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS + AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF + ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, + IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, + WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR + PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, + ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT + KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT + ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. + + b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE + TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, + NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, + INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, + COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR + USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR + DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR + IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. + + c. The disclaimer of warranties and limitation of liability provided + above shall be interpreted in a manner that, to the extent + possible, most closely approximates an absolute disclaimer and + waiver of all liability. + + +Section 6 -- Term and Termination. + + a. This Public License applies for the term of the Copyright and + Similar Rights licensed here. However, if You fail to comply with + this Public License, then Your rights under this Public License + terminate automatically. + + b. Where Your right to use the Licensed Material has terminated under + Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided + it is cured within 30 days of Your discovery of the + violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any + right the Licensor may have to seek remedies for Your violations + of this Public License. + + c. For the avoidance of doubt, the Licensor may also offer the + Licensed Material under separate terms or conditions or stop + distributing the Licensed Material at any time; however, doing so + will not terminate this Public License. + + d. Sections 1, 5, 6, 7, and 8 survive termination of this Public + License. + + +Section 7 -- Other Terms and Conditions. + + a. The Licensor shall not be bound by any additional or different + terms or conditions communicated by You unless expressly agreed. + + b. Any arrangements, understandings, or agreements regarding the + Licensed Material not stated herein are separate from and + independent of the terms and conditions of this Public License. + + +Section 8 -- Interpretation. + + a. For the avoidance of doubt, this Public License does not, and + shall not be interpreted to, reduce, limit, restrict, or impose + conditions on any use of the Licensed Material that could lawfully + be made without permission under this Public License. + + b. To the extent possible, if any provision of this Public License is + deemed unenforceable, it shall be automatically reformed to the + minimum extent necessary to make it enforceable. If the provision + cannot be reformed, it shall be severed from this Public License + without affecting the enforceability of the remaining terms and + conditions. + + c. No term or condition of this Public License will be waived and no + failure to comply consented to unless expressly agreed to by the + Licensor. + + d. Nothing in this Public License constitutes or may be interpreted + as a limitation upon, or waiver of, any privileges and immunities + that apply to the Licensor or You, including from the legal + processes of any jurisdiction or authority. + + +======================================================================= + +Creative Commons is not a party to its public +licenses. Notwithstanding, Creative Commons may elect to apply one of +its public licenses to material it publishes and in those instances +will be considered the “Licensor.” The text of the Creative Commons +public licenses is dedicated to the public domain under the CC0 Public +Domain Dedication. Except for the limited purpose of indicating that +material is shared under a Creative Commons public license or as +otherwise permitted by the Creative Commons policies published at +creativecommons.org/policies, Creative Commons does not authorize the +use of the trademark "Creative Commons" or any other trademark or logo +of Creative Commons without its prior written consent including, +without limitation, in connection with any unauthorized modifications +to any of its public licenses or any other arrangements, +understandings, or agreements concerning use of licensed material. For +the avoidance of doubt, this paragraph does not form part of the +public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/config.yml b/config.yml index 1c837f8..32ea40c 100644 --- a/config.yml +++ b/config.yml @@ -2,11 +2,46 @@ title: "GitHub Actions: Using GitHub Script" description: >- This course covers how to use GitHub Script to quickly use octokit/rest in a GitHub Actions workflow. +tags: + - GitHub Actions + - Octokit + - Workflow + - Automation + - Application programming interface (API) template: repo: write-github-script-template name: write-github-script + +# Repo artifacts +# repositoryUrl +# actionsUrl +# 1. (Issue) Start here! +# welcomeIssueUrl +# welcomeIssueNumber +# 2. (PR) Learner created PR, "Automate issue response" possibly +# firstPullNumber +# firstPullUrl +# 3. (Issue) Create an issue comment with GitHub Script +# secondIssueNumber +# secondIssueUrl +# 4. (PR) Learner created PR, "Add issues to project board" possibly +# secondPullNumber +# secondPullUrl +# 5. (Issue) Comment and triage with GitHub Script +# thirdIssueUrl +# thirdIssueNumber +# 6. (PR) Learner created PR, "Create better comments" possibly +# thirdPullNumber +# thirdPullUrl +# 7. (Issue) It's alive! +# fourthIssueUrl +# fourthIssueNumber + before: - type: updateBranchProtection + store: + repositoryUrl: '{{ payload.repository.html_url }}' + actionsUrl: '{{ payload.repository.html_url }}/actions' - type: createProjectBoard name: Learning Lab Project Board description: >- @@ -14,59 +49,40 @@ before: columns: - Triage Backlog - Triage Complete + store: + projectUrl: "{{ result.data.html_url }}" - type: createIssue title: Start here! body: 00_welcome-issue.md - action_id: welcomeIssue - - type: respond - with: 00_explain-gh-script.md - issue: "%actions.welcomeIssue.data.number%" - - type: respond - with: 00_octokit-comparison.md - issue: "%actions.welcomeIssue.data.number%" - - type: respond - issue: "%actions.welcomeIssue.data.number%" - with: 00_welcome-activity.md + store: + welcomeIssueUrl: "%result.data.html_url%" + welcomeIssueNumber: "%result.data.number%" data: - quicklink: "%payload.repository.html_url%/new/master?filename=.github/workflows/my-workflow.yml" - actionsUrl: "%payload.repository.html_url%/actions/new" + quicklink: "{{ store.repositoryUrl }}/new/master?filename=.github/workflows/my-workflow.yml" + actionsUrl: "{{ store.repositoryUrl }}/actions/new" + comments: + - 00_explain-gh-script.md + - 00_octokit-comparison.md + - 00_welcome-activity.md steps: - - title: Setup a workflow file + - title: Start here! description: Create a pull request to add a workflow - event: pull_request - link: "{{ repoUrl }}/issues/1" + event: + - pull_request.opened + - pull_request.edited + link: "{{store.welcomeIssueUrl}}" actions: - - type: gate - gates: - # if the payload action is 'opened' OR 'edited' - - left: "%payload.action%" - operator: === - right: opened - - left: "%payload.action%" - operator: === - right: edited - # AND the pull request title equals 'Create my-workflow.yml' - - type: gate - left: "%payload.pull_request.title%" - operator: === - right: Create my-workflow.yml - - # if those statments FAIL... do this - else: - - type: respond - with: e-rename-pr.md - data: - title: Create my-workflow.yml - # if those gates === true Then do this stuff - - ####################################################### # Validate the filepath for the my-workflow.yml file # get tree - type: getTree action_id: isInTree recursive: true sha: "%payload.pull_request.head.sha%" + store: + firstPullNumber: "%payload.pull_request.number%" + firstPullUrl: "%payload.pull_request.html_url%" + # check for a file in a tree - type: gate left: "%actions.isInTree.data.tree%" @@ -77,110 +93,101 @@ steps: - type: findInTree path: my-workflow.yml tree: "%actions.isInTree.data.tree%" - # multiple: true action_id: fileLocation # help user with proper file location - type: respond with: e-wrong-file-location.md data: haveFile: "%actions.fileLocation.path%" - needFile: ".github/actions/cat-facts/action.yml" + needFile: ".github/workflows/my-workflow.yml" editLink: "%payload.repository.html_url%/edit/%payload.pull_request.head.ref%/%actions.fileLocation.path%" fileName: my-workflow.yml # End filepath verification ####################################################### - type: respond - issue: Start here! + issue: "%store.welcomeIssueNumber%" with: new-pull-request.md data: - pullUrl: "%payload.pull_request.html_url%" + pullUrl: '{{ store.firstPullUrl }}' - type: closeIssue - issue: Start here! + issue: "%store.welcomeIssueNumber%" - type: createReview body: 01_merge-workflow.md event: APPROVE - data: - actionsUrl: "%payload.repository.html_url%/actions" - - title: Merge the new workflow into the master branch - description: Make the workflow available for use on the repository + - title: Merge your first pull request + description: Make the workflow available to the repository by merging the pull request event: pull_request.closed - link: "{{ repoUrl }}/pull/2" + link: "{{store.firstPullUrl}}" actions: + - type: gate + every: true + gates: + - left: '{{ payload.pull_request.number }}' + operator: === + right: '{{ store.firstPullNumber }}' + - left: '{{ payload.pull_request.merged }}' + else: + - type: respond + with: e-generic.md + data: + expected: merge pull request '{{ store.firstPullNumber }}' - type: createIssue title: Create an issue comment with GitHub Script body: 02_workflow-triggered.md - action_id: triggerIssue + store: + secondIssueNumber: "%result.data.number%" + secondIssueUrl: "%result.data.html_url%" - type: respond with: new-issue.md - issue: Create my-workflow.yml + issue: "%store.firstPullNumber%" data: - issueURL: "%actions.triggerIssue.data.html_url%" + issueUrl: '{{ store.secondIssueUrl }}' - title: Add another GitHub Script action description: Use GitHub Script to place this issue into a project board - event: check_suite.completed - link: "{{repoUrl}}/issues/3" + # event: check_suite.completed # issue_comment.created/edited + event: issue_comment.created + link: "{{store.secondIssueUrl}}" actions: - type: gate - left: "%payload.check_suite.app.name%" + left: "%payload.comment.user.login%" operator: === - right: "GitHub Actions" + right: "github-actions[bot]" else: - type: respond - issue: 3 + issue: "%store.secondIssueNumber%" with: debug.md data: debug: "%payload%" - type: respond with: 03_workflow-success.md - issue: 3 + issue: "%store.secondIssueNumber%" - type: octokit method: projects.listForRepo owner: "%payload.repository.owner.login%" repo: "%payload.repository.name%" - action_id: projectBoard + store: + boardID: "%result.data.0.id%" - type: octokit method: projects.listColumns - project_id: "%actions.projectBoard.data.0.id%" - action_id: listColumns + project_id: "%store.boardID%" + store: + columnID: "%result.data.0.id%" - type: respond with: 03_add-to-projects.md - issue: 3 + issue: "%store.secondIssueNumber%" data: - listProj: "%actions.projectBoard.data%" - listCol: "%actions.listColumns.data%" - columnID: "%actions.listColumns.data.0.id%" + columnID: "%store.columnID%" quicklink: "%payload.repository.html_url%/edit/master/.github/workflows/my-workflow.yml" # new pull request - title: Modify your workflow file description: Create a pull request to add changes to your workflow - event: pull_request - link: "{{ repoUrl }}/pull/4" + event: + - pull_request.opened + - pull_request.edited + link: "{{ store.secondIssueUrl }}" actions: - - type: gate - gates: - # if the payload action is 'opened' OR 'edited' - - left: "%payload.action%" - operator: === - right: opened - - left: "%payload.action%" - operator: === - right: edited - # AND the pull request title equals 'Create my-workflow.yml' - - type: gate - left: "%payload.pull_request.title%" - operator: === - right: Update my-workflow.yml - - # if those statments FAIL... do this - else: - - type: respond - with: e-rename-pr.md - data: - title: Update my-workflow.yml - # if those gates === true Then do this stuff - ####################################################### # Validate the filepath for the my-workflow.yml file # get tree @@ -188,6 +195,9 @@ steps: action_id: isInTree recursive: true sha: "%payload.pull_request.head.sha%" + store: + secondPullNumber: "%payload.pull_request.number%" + secondPullUrl: "%payload.pull_request.html_url%" # check for a file in a tree - type: gate left: "%actions.isInTree.data.tree%" @@ -211,45 +221,60 @@ steps: # End filepath verification ####################################################### - type: respond - issue: 3 + issue: "%store.secondIssueNumber%" with: new-pull-request.md data: - pullUrl: "%payload.pull_request.html_url%" + pullUrl: "%store.secondPullUrl%" - type: closeIssue - issue: 3 + issue: "%store.secondIssueNumber%" - type: createReview body: 04_merge-workflow.md event: APPROVE data: actionsUrl: "%payload.repository.html_url%/actions" - - title: Merge the new workflow into the master branch + - title: Merge the updated workflow into the master branch description: Make the workflow available for use on the repository event: pull_request.closed - link: "{{ repoUrl }}/issues/5" + link: "{{ store.secondPullUrl }}" actions: + - type: gate + every: true + gates: + - left: '{{ payload.pull_request.number }}' + operator: === + right: '{{ store.secondPullNumber }}' + - left: '{{ payload.pull_request.merged }}' + else: + - type: respond + with: e-generic.md + data: + expected: merge pull request '{{ store.secondPullNumber }}' - type: createIssue - title: Create an issue comment with GitHub Script + title: Comment and triage with GitHub Script body: 05_workflow-triggered.md action_id: triggerIssue + store: + thirdIssueUrl: "%result.data.html_url%" + thirdIssueNumber: "%result.data.number%" - type: respond with: new-issue.md - issue: Update my-workflow.yml + issue: "%store.secondPullNumber%" data: - issueURL: "%actions.triggerIssue.data.html_url%" + issueUrl: "%store.thirdIssueUrl%" - title: Break your workflow into multiple steps description: Separate the workflow concerns by adding more steps - event: check_suite.completed - link: "{{repoUrl}}/issues/5" + event: issue_comment.created + link: "{{store.thirdIssueUrl}}" actions: - type: gate - left: "%payload.check_suite.app.name%" + left: "%payload.comment.user.login%" operator: === - right: "GitHub Actions" + right: "github-actions[bot]" else: - type: respond - issue: 5 + issue: "%store.secondIssueNumber%" with: debug.md data: debug: "%payload%" @@ -264,40 +289,44 @@ steps: action_id: listColumns - type: respond with: 06_steps-overview.md - issue: 5 + issue: "%store.thirdIssueNumber%" data: projectTab: "%payload.repository.html_url%/projects/1" - type: respond with: 06_steps-activity.md - issue: 5 + issue: "%store.thirdIssueNumber%" data: listProj: "%actions.projectBoard.data%" listCol: "%actions.listColumns.data%" columnID: "%actions.listColumns.data.0.id%" quicklink: "%payload.repository.html_url%/edit/master/.github/workflows/my-workflow.yml" - actionsTab: "%paylaod.repository.html_url%/actions" - title: Create better comments description: Use a templated repsonse as the comment body - event: pull_request - link: "{{repoUrl}}/pull/6" + event: + - pull_request.opened + - pull_request.edited + link: "{{store.thirdPullUrl}}" actions: - type: octokit method: projects.listForRepo owner: "%payload.repository.owner.login%" repo: "%payload.repository.name%" action_id: projectBoard + store: + thirdPullNumber: "%payload.pull_request.number%" + thirdPullUrl: "%payload.pull_request.html_url%" - type: octokit method: projects.listColumns project_id: "%actions.projectBoard.data.0.id%" action_id: listColumns - type: respond - issue: 5 + issue: "%store.thirdIssueNumber%" with: new-pull-request.md data: - pullUrl: "%payload.pull_request.html_url%" + pullUrl: "%store.thirdPullUrl%" - type: closeIssue - issue: 5 + issue: "%store.thirdIssueNumber%" - type: respond with: 07_explain-node.md - type: respond @@ -306,20 +335,41 @@ steps: columnID: "%actions.listColumns.data.0.id%" quicklink: "%payload.repository.html_url%/edit/%payload.pull_request.head.ref%/.github/workflows/my-workflow.yml" - - title: Merge the final workflow - description: Merge the final workflow into the repository + - title: Use a templated response + description: Create the comment body from a template using the Node.js file system module event: pull_request.synchronize - link: "{{repoUrl}}/pull/6" + link: "{{store.thirdPullUrl}}" actions: + - type: gate + left: '{{ payload.pull_request.number }}' + operator: === + right: '{{ store.thirdPullNumber }}' + else: + - type: respond + with: e-generic.md + data: + expected: push a commit to '{{ store.thirdPullNumber }}' - type: createReview body: 08_merge-workflow.md event: APPROVE - - title: See workflow results - description: See the results of the final workflow run + - title: Merge the updated workflow + description: Merge the worklow to the master branch event: pull_request.closed - link: "{{repoUrl}}/issue/7" + link: "{{store.thirdPullUrl}}" actions: + - type: gate + every: true + gates: + - left: '{{ payload.pull_request.number }}' + operator: === + right: '{{ store.thirdPullNumber }}' + - left: '{{ payload.pull_request.merged }}' + else: + - type: respond + with: e-generic.md + data: + expected: merge pull request '{{ store.thirdPullNumber }}' - type: octokit action_id: triggerIssue method: issues.create @@ -335,24 +385,34 @@ steps: I'll respond here once it has completed! labels: ["bug"] + store: + fourthIssueUrl: "%result.data.html_url%" + fourthIssueNumber: "%result.data.number%" - type: respond with: new-issue.md - issue: 6 + issue: "%store.thirdPullNumber%" data: - issueURL: "%actions.triggerIssue.data.html_url%" + issueUrl: "%store.fourthIssueUrl%" - - title: Open an issue - description: Open another issue that does not contain the bug tag + - title: Another workflow run + description: Observe the results of an enhanced workflow run event: check_suite.completed - link: "{{repoUrl}}/issue/7" + link: "{{store.fourthIssueUrl}}" actions: + - type: gate + left: "%payload.check_suite.app.name%" + operator: === + right: "GitHub Actions" + else: + - type: respond + with: e-action-result.md - type: respond with: 09_workflow-completed.md - issue: 7 + issue: "%store.fourthIssueNumber%" - type: respond with: 09_issue-activity.md - issue: 7 + issue: "%store.fourthIssueNumber%" data: quicklink: "%payload.repository.html_url%/issues/new" @@ -361,6 +421,13 @@ steps: event: check_suite.completed link: "{{repoUrl}}/issue/8" actions: + - type: gate + left: "%payload.check_suite.app.name%" + operator: === + right: "GitHub Actions" + else: + - type: respond + with: e-action-result.md - type: respond with: 10_workflow-completed.md issue: 8 diff --git a/course-details.md b/course-details.md index 629148e..0d4e726 100644 --- a/course-details.md +++ b/course-details.md @@ -1,9 +1,35 @@ -This is the description we show on the course page [here](https://lab.github.com/githubtraining/write-github-script). This first paragraph will be featured at the top of the page so make it great. -​ +[GitHub Script](https://github.com/actions/github-script) is a special action that allows using [octokit/rest.js](https://octokit.github.io/rest.js/v17) directly in a workflow file. -​ -Be sure to tell the learner about the technology you are teaching, why they should learn it, how they can use it, and what you will teach them. -​ +Over the duration of this course you will learn the skills needed to begin using the GitHub Script action to interact with your repository which will save you from creating full blown actions that carry unnecessary overhead. +## What you'll learn -Include information on how they can reach you for questions about the content or course. \ No newline at end of file +In this course you will learn how to: + +- Use GitHub Script in your workflow +- Comment on issues using octokit +- Add issues to a project board using octokit +- Use the workflow expression syntax to filter when jobs run in a workflow. + +## What you'll build + +![A user opens an issue, the GitHub Actions bot responds with a welcome message. Another window shows that the issue has been added to a project board.](https://user-images.githubusercontent.com/16547949/78669798-cf8b2e80-78aa-11ea-885e-65e72fa22379.png) + +In this course you will automatically generate a comment on every new issue using a templated response. Additionally, if this issue is labeled as a bug it will be automatically added to the "needs triage" column of a project board. + +## Prerequisites + +We first recommend taking the following courses: + +- [Hello, GitHub Actions!](https://lab.github.com/github/hello-github-actions!) to learn the basics of how GitHub Actions work +- [GitHub Actions: Continuous Integration](https://lab.github.com/githubtraining/github-actions:-continuous-integration) to dive deeper into a workflow file + +## Projects used + +This makes use of the following open source projects. Consider exploring these repos and maybe even making contributions! + +- [GitHub Script](https://github.com/actions/github-script), a unique action that provides an authenticated octokit client and allows JavaScript to be written directly in a workflow file. + +## Audience + +Developers, DevOps Engineers, students, teams diff --git a/responses/00_welcome-activity.md b/responses/00_welcome-activity.md index 7227dd3..e595833 100644 --- a/responses/00_welcome-activity.md +++ b/responses/00_welcome-activity.md @@ -20,7 +20,7 @@ Your repository can contain multiple **workflow** files that carry out a wide va 📖 Read more about [workflows](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/configuring-a-workflow#choosing-the-type-of-actions-for-your-workflow) -### :keyboard: Activity: Respond to an issue when it get's opened +### :keyboard: Activity: Respond to an issue when it gets opened 1. Create a new workflow file titled `.github/workflows/my-workflow.yml` with the following contents: You can use [this quicklink]({{quicklink}}) to easily create this file @@ -49,17 +49,21 @@ Your repository can contain multiple **workflow** files that carry out a wide va ``` 1. Commit the workflow to a new branch. -1. Create a pull request titled **Create my-workflow.yml**. -1. Supply the pull request body content and click `Create pull request`. +1. Create a pull request. I suggest a title like **Automate issue responses**. +1. Supply the pull request body content and click **Create pull request**. -_It is important to place meaningful content into the body of the pull requests you create throughout this course. This repository will stay with you long after you complete the course. It is advisable that you use the body of the pull requests you create as a way to take long lived notes about thing you want to remember._ +
About pull pull request titles and content -
Suggested body content +It is important to place meaningful content into the body of the pull requests you create. This repository will stay with you long after you complete the course. We recommend you use the body of your pull requests as a way to take long lived notes about thing you want to remember. -`Workflow files are the recipe for task automation. This is where actions are placed if I want to use them for a task.` +In practice, good pull request titles and content convey information efficiently to your collaborators. + +You can fill the body of this pull request with the following recommended content: + +> Workflow files are the recipe for task automation. This is where actions are placed if I want to use them for a task.
--- -I'll respond in the new pull request when I detect it has been created. +I am waiting for you to create a new pull request before moving on. diff --git a/responses/01_merge-workflow.md b/responses/01_merge-workflow.md index d2b2eaf..74a4850 100644 --- a/responses/01_merge-workflow.md +++ b/responses/01_merge-workflow.md @@ -8,12 +8,12 @@ Let's go ahead and do this now. ### :keyboard: Activity: Merge the workflow -When you are ready, merge this pull request. +1. Merge this pull request. --- -Once you have merged this pull request I will open a new issue so we can see this workflow in action! +I am waiting for you to merge this pull request before moving on. -Oh, I'll also be responding to you from that issue! +Once you have merged this pull request I will open a new issue so we can see this workflow in action!
Trouble merging?Try refreshing the page!
diff --git a/responses/02_workflow-triggered.md b/responses/02_workflow-triggered.md index 910e212..b523e6f 100644 --- a/responses/02_workflow-triggered.md +++ b/responses/02_workflow-triggered.md @@ -10,7 +10,7 @@ on: types: [opened] ``` -This means that every time an issue get's opened in this repository the GitHub Script you wrote will execute. +This means that every time an issue gets opened in this repository the GitHub Script you wrote will execute. You should expect to see the result right here in this issue! diff --git a/responses/03_add-to-projects.md b/responses/03_add-to-projects.md index 20d1223..bf909d5 100644 --- a/responses/03_add-to-projects.md +++ b/responses/03_add-to-projects.md @@ -1,6 +1,6 @@ # Let's add a card to a project board -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! +We have added [a project board]({{ store.projectUrl }}) 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! 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! @@ -45,9 +45,11 @@ We've gone ahead and done this on our end of things so that we could give you th ``` 2. Commit the workflow to a new branch. -3. Create a pull request titled **Update my-workflow.yml**. -4. Supply the pull request body content and click `Create pull request`. +3. Create a pull request, I suggest the title **Add issues to project board**. +4. Supply the pull request body content and click **Create pull request**. --- +I am waiting for you to create a new pull request before moving on. + I'll respond in the new pull request when I detect it has been created. diff --git a/responses/04_merge-workflow.md b/responses/04_merge-workflow.md index d097a58..5f44b71 100644 --- a/responses/04_merge-workflow.md +++ b/responses/04_merge-workflow.md @@ -2,7 +2,7 @@ @{{user.login}}, you're a rockstar ✨ -You'r workflow now has the necessary updates for us to have new issues automatically added to the triage board when they are created! +Your workflow now has the necessary updates for us to have new issues automatically added to the triage board when they are created! 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. @@ -14,6 +14,8 @@ When you are ready, merge this pull request. --- +I am waiting for you to merge this pull request before moving on. + Once you have merged this pull request I will open a new issue so we can see this workflow in action!
Trouble merging?Try refreshing the page!
diff --git a/responses/06_steps-activity.md b/responses/06_steps-activity.md index 191068f..d1973b9 100644 --- a/responses/06_steps-activity.md +++ b/responses/06_steps-activity.md @@ -2,12 +2,12 @@ We will make the following changes to the current workflow file: -- Name each step so we can easily keep track of it in the [actions tab]({{actionTab}}) +- Name each step so we can easily keep track of it in the [actions tab]({{store.actionsUrl}}) - Use expressions to determine `if` a step should execute ### :keyboard: Activity: Add newly opened issue to project board -1. [Edit]({{quicklink}}) the current workflow `.github/workflows/my-workflow.yml` to have he following contents: +1. [Edit]({{quicklink}}) the current workflow `.github/workflows/my-workflow.yml` to have the following contents: ```yaml name: Learning GitHub Script @@ -47,9 +47,11 @@ We will make the following changes to the current workflow file: ``` 2. Commit the workflow to a new branch. -3. Create a pull request titled **Update my-workflow.yml**. -4. Supply the pull request body content and click `Create pull request`. +3. Create a pull request, I suggest the title **Create better comments**. +4. Supply the pull request body content and click **Create pull request**. --- +I am waiting for you to create a new pull request before moving on. + I'll respond in the pull request you create diff --git a/responses/07_use-fs.md b/responses/07_use-fs.md index 79ff44e..e9188b5 100644 --- a/responses/07_use-fs.md +++ b/responses/07_use-fs.md @@ -55,4 +55,6 @@ We will make the following changes to the current workflow file: --- +I am waiting for you to commit the desired changes to this branch before moving on. + I'll respond once you've committed the changes to this branch diff --git a/responses/08_merge-workflow.md b/responses/08_merge-workflow.md index de5f66d..da1b423 100644 --- a/responses/08_merge-workflow.md +++ b/responses/08_merge-workflow.md @@ -8,6 +8,8 @@ When you are ready, merge this pull request. --- +I am waiting for you to merge this pull request before moving on. + Once you have merged this pull request I will open a new issue so we can see this workflow in action!
Trouble merging?Try refreshing the page!
diff --git a/responses/09_issue-activity.md b/responses/09_issue-activity.md index 07e4b8c..20874e3 100644 --- a/responses/09_issue-activity.md +++ b/responses/09_issue-activity.md @@ -8,4 +8,6 @@ --- +I am waiting for you to open a new issue before moving on. + I'll respond in your new issue once you've opened it diff --git a/responses/e-action-result.md b/responses/e-action-result.md new file mode 100644 index 0000000..4745e34 --- /dev/null +++ b/responses/e-action-result.md @@ -0,0 +1,3 @@ +# Oops! + +It seems like there is an issue with your workflow run. You'll need to head to the actions tab to troubleshoot your workflow diff --git a/responses/e-generic.md b/responses/e-generic.md new file mode 100644 index 0000000..4d86027 --- /dev/null +++ b/responses/e-generic.md @@ -0,0 +1,3 @@ +Oops! I was expecting you to take **{{ expected }}**. + +I'll respond when you take the expected action. \ No newline at end of file diff --git a/responses/e-result.md b/responses/e-result.md new file mode 100644 index 0000000..d54739a --- /dev/null +++ b/responses/e-result.md @@ -0,0 +1,7 @@ +# action_id + +{{actionIdData}} + +# result + +{{resultData}} diff --git a/responses/new-issue.md b/responses/new-issue.md index 64fe506..2513b48 100644 --- a/responses/new-issue.md +++ b/responses/new-issue.md @@ -1,3 +1,3 @@ ## A new issue has been opened -I have created a [new issue]({{issueURL}}) where we will continue this lesson. Click the link to meet me over there. +I have created a [new issue]({{issueUrl}}) where we will continue this lesson. Click the link to meet me over there. diff --git a/server-installation-notes.md b/server-installation-notes.md new file mode 100644 index 0000000..ced1ca8 --- /dev/null +++ b/server-installation-notes.md @@ -0,0 +1,24 @@ +## GitHub Enterprise Server (GHES) installation notes + + + +| 🚫 | This course needs features not yet supported by GHES. | +| --- | ----------------------------------------------------- | + + +This course makes use of [GitHub Actions](https://github.com/features/actions), a feature that is currently available for GitHub.com but not available on GHES. + + + +### Course dependencies + +The following are dependencies of the course. The course may continue to work without these dependencies, but learners won't experience the course as designed. + + + +| Dependency | Required? | Reason | Alternative | +| -------------------------------------------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| GHES must be able to reach githubusercontent.com | Yes | Images used throughout the course are served from this domain. Learners will find broken images required to take the course without this access. | Manually download the images referenced in the `responses/` folder, upload them to an accessible domain, and replace the images in the `responses/` folder. | +| Learner must be able to reach github.com and outside web | Yes | Links are provided to resources that live on the outside web. | Without access to resources on the outside web, learners will reach blocked resources. You can change the links to these resources in the `responses/` folder, and in the template repository. | + +| pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy