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

Commit

Permalink
Merge pull request #17 from github/update-to-v2
Browse files Browse the repository at this point in the history
Update course content
  • Loading branch information
mattdavis0351 authored Mar 4, 2020
2 parents 898116f + 69bbba6 commit ac0d62b
Show file tree
Hide file tree
Showing 14 changed files with 291 additions and 212 deletions.
310 changes: 165 additions & 145 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,163 +6,183 @@ tags:
- Workflows
- Hello World
template:
name: hello-github-actions
repo: hello-github-actions-template
name: hello-github-actions
repo: hello-github-actions-template
before:
# protect the master branch
- type: updateBranchProtection
# protect the master branch
- type: updateBranchProtection

# open issue 1 (welcome)
- type: createIssue
title: Welcome
body: 00.0_welcome.md
comments:
- 00.1_first-steps.md
data:
dockerfileUrl: '%payload.repository.html_url%/new/master?filename=action-a/Dockerfile'
# open issue 1 (welcome)
- type: createIssue
title: Welcome
body: 00.0_welcome.md
comments:
- 00.1_first-steps.md
data:
dockerfileUrl: "%payload.repository.html_url%/new/master?filename=action-a/Dockerfile"

# Repo artifacts:
# Issue 1: Welcome
# PR 2: (created by learner) houses the addition of the Dockerfile, entrypoint script, and workflow
# Issue 3: Congratulations

steps:
# 1 - Add a Dockerfile
- title: Add a Dockerfile
description: Start your action by creating a Dockerfile
event: pull_request
link: "{{ repoUrl }}/issues/1"
actions:
- type: gate
gates:
- left: "%payload.action%"
operator: ===
right: opened
- left: "%payload.action%"
operator: ===
right: synchronize
- type: getTree
action_id: tree
recursive: true
sha: "%payload.pull_request.head.sha%"
- type: gate
left: "%actions.tree.data.tree%"
operator: includes
right: path:action-a/Dockerfile
else:
type: respond
with: 01.1_e-no-docker.md
- type: respond
with: 01.0_docker-success.md
data:
actionAUrl: "%payload.repository.html_url%/new/%payload.pull_request.head.ref%?filename=action-a/entrypoint.sh"
- type: closeIssue
issue: Welcome

# 1 - Add a Dockerfile
- title: Add a Dockerfile
description: Start your action by creating a Dockerfile
event: pull_request
link: '{{ repoUrl }}/issues/1'
actions:
- type: gate
gates:
- left: '%payload.action%'
operator: ===
right: opened
- left: '%payload.action%'
operator: ===
right: synchronize
- type: getTree
action_id: tree
recursive: true
sha: '%payload.pull_request.head.sha%'
- type: gate
left: '%actions.tree.data.tree%'
operator: includes
right: path:action-a/Dockerfile
else:
type: respond
with: 01.1_e-no-docker.md
- type: respond
with: 01.0_docker-success.md
data:
actionAUrl: '%payload.repository.html_url%/new/%payload.pull_request.head.ref%?filename=action-a/entrypoint.sh'
- type: closeIssue
issue: Welcome

# 2 - Add an entrypoint script
- title: Add an entrypoint script
description: Script out how your action will run with an entrypoint script
event: pull_request.synchronize
link: '{{ repoUrl }}/pull/2'
actions:
- type: getTree
action_id: tree
recursive: true
sha: '%payload.pull_request.head.sha%'
- type: gate
left: '%actions.tree.data.tree%'
operator: includes
right: path:action-a/entrypoint.sh
else:
type: respond
with: 02.1_e-no-entrypoint.md
- type: respond
with: 02.0_entrypoint-success.md
data:
worfkflowUrl: '%payload.repository.html_url%/new/%payload.pull_request.head.ref%?filename=.github/workflows/main.yml'
# 2 - Add an entrypoint script
- title: Add an entrypoint script
description: Script out how your action will run with an entrypoint script
event: pull_request.synchronize
link: "{{ repoUrl }}/pull/2"
actions:
- type: getTree
action_id: tree
recursive: true
sha: "%payload.pull_request.head.sha%"
- type: gate
left: "%actions.tree.data.tree%"
operator: includes
right: path:action-a/entrypoint.sh
else:
type: respond
with: 02.1_e-no-entrypoint.md
- type: respond
with: 02.0_entrypoint-success.md
data:
actionAUrl: "%payload.repository.html_url%/new/%payload.pull_request.head.ref%?filename=action-a/action.yml"

# 3 - Start your workflow file
- title: Start your workflow file
description: Get your workflow kicked off with the workflow file
event: pull_request.synchronize
link: '{{ repoUrl }}/pull/2'
actions:
- type: getTree
action_id: tree
recursive: true
sha: '%payload.pull_request.head.sha%'
- type: gate
left: '%actions.tree.data.tree%'
operator: includes
right: path:/^.github/workflows/main.yml$/
else:
type: respond
with: 03.1_e-no-workflow.md
- type: respond
with: 03.0_workflow-block-success.md
data:
workflowEditUrl: '%payload.repository.html_url%/edit/%payload.pull_request.head.ref%/.github/workflows/main.yml?pr=/%payload.repository.full_name%/pull/%payload.number%'
# 3 - Add action metadata
- title: Add an action.yml file
description: Create the necessary metadata for the action
event: pull_request.synchronize
link: "{{ repoUrl }}/pull/2"
actions:
- type: getTree
action_id: tree
recursive: true
sha: "%payload.pull_request.head.sha%"
- type: gate
left: "%actions.tree.data.tree%"
operator: includes
right: path:action-a/action.yml
else:
type: respond
with: 03.1_e-no-actionyml.md
- type: respond
with: 03.0_actionyml-success.md
data:
worfkflowUrl: "%payload.repository.html_url%/new/%payload.pull_request.head.ref%?filename=.github/workflows/main.yml"

# 4 - Run an action from your workflow file
- title: Run an action from your workflow file
description: Specify a job and call actions within your workflow file
event: pull_request.synchronize
link: '{{ repoUrl }}/pull/2'
actions:
- type: getTree
action_id: tree
recursive: true
sha: '%payload.pull_request.head.sha%'
- type: gate
left: '%actions.tree.data.tree%'
operator: includes
right: path:/^.github/workflows/main.yml$/
else:
type: respond
with: 03.1_e-no-workflow.md
- type: respond
with: 04.0_trigger.md
# 4 - Start your workflow file
- title: Start your workflow file
description: Get your workflow kicked off with the workflow file
event: pull_request.synchronize
link: "{{ repoUrl }}/pull/2"
actions:
- type: getTree
action_id: tree
recursive: true
sha: "%payload.pull_request.head.sha%"
- type: gate
left: "%actions.tree.data.tree%"
operator: includes
right: path:/^.github/workflows/main.yml$/
else:
type: respond
with: 04.1_e-no-workflow.md
- type: respond
with: 04.0_workflow-block-success.md
data:
workflowEditUrl: "%payload.repository.html_url%/edit/%payload.pull_request.head.ref%/.github/workflows/main.yml?pr=/%payload.repository.full_name%/pull/%payload.number%"

# 5 - Run an action from your workflow file
- title: Run an action from your workflow file
description: Specify a job and call actions within your workflow file
event: pull_request.synchronize
link: "{{ repoUrl }}/pull/2"
actions:
- type: getTree
action_id: tree
recursive: true
sha: "%payload.pull_request.head.sha%"
- type: gate
left: "%actions.tree.data.tree%"
operator: includes
right: path:/^.github/workflows/main.yml$/
else:
type: respond
with: 04.1_e-no-workflow.md
- type: respond
with: 05.0_trigger.md

# 5 - Trigger the workflow
- title: Trigger the workflow
description: See your push trigger the workflow you've created and run your action
event: check_run.completed
link: '{{ repoUrl }}/pull/2'
actions:
- type: gate
left: '%payload.check_run.conclusion%'
operator: ===
right: success
else:
- type: respond
issue: '%payload.check_run.pull_requests.0.number%'
with: 05.1_e-no-run.md
data:
repo: '%payload.repository.html_url%'
- type: createReview
pullRequest: '%payload.check_run.pull_requests.0.number%'
body: 05.0_workflow-success.md
event: APPROVE
data:
repo: '%payload.repository.html_url%'
# 6 - Trigger the workflow
- title: Trigger the workflow
description: See your push trigger the workflow you've created and run your action
event: check_run.completed
link: "{{ repoUrl }}/pull/2"
actions:
- type: gate
left: "%payload.check_run.conclusion%"
operator: ===
right: success
else:
- type: respond
issue: "%payload.check_run.pull_requests.0.number%"
with: 06.1_e-no-run.md
data:
repo: "%payload.repository.html_url%"
- type: createReview
pullRequest: "%payload.check_run.pull_requests.0.number%"
body: 06.0_workflow-success.md
event: APPROVE
data:
repo: "%payload.repository.html_url%"

# 6 - Incorporate the action
- title: Incorporate the workflow
description: Merge your branch for the workflow to become incorporated
event: pull_request.closed
link: '{{ repoUrl }}/pull/2'
actions:
- type: gate
left: '%payload.pull_request.merged%'
- type: createIssue
title: Congratulations
body: 06.0_workflow-finished.md
data:
repo: '%payload.repository.html_url%'
action_id: congratsIssue
- type: respond
with: 06.1_go-to-final.md
data:
url: '%actions.congratsIssue.data.html_url%'
# 7 - Incorporate the action
- title: Incorporate the workflow
description: Merge your branch for the workflow to become incorporated
event: pull_request.closed
link: "{{ repoUrl }}/pull/2"
actions:
- type: gate
left: "%payload.pull_request.merged%"
- type: createIssue
title: Congratulations
body: 07.0_workflow-finished.md
data:
repo: "%payload.repository.html_url%"
action_id: congratsIssue
- type: respond
with: 07.1_go-to-final.md
data:
url: "%actions.congratsIssue.data.html_url%"
39 changes: 19 additions & 20 deletions responses/00.1_first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,34 @@ Docker **container actions** allow the environment to be packaged with the GitHu

**JavaScript actions** decouple the GitHub Actions code from the environment allowing faster execution but accepting greater dependency management responsibility.

<!--
UNCOMMENT WHEN THESE TWO COURSE GO LIVE AND ADD PROPER LINK DETAILS
📖 To learn more about creating each type of action, refer to the related learning lab course:
- [Writing JavaScript Actions]()
- [Writing Docker Container Actions]() -->

## Step 1: Add a `Dockerfile`

Our action will use a Docker container so it will require a `Dockerfile`. Let's add it now. We won't discuss what each line means in detail, but the important thing to know is that the action will be executed in an environment defined by this file.

### :keyboard: Activity: Create a `Dockerfile` and open a pull request

1. Create a file titled `action-a/Dockerfile` by [using this quick link]({{ dockerfileUrl }}) or manually:
- Create a new branch. _Branches should be named intentionally, so a good name for this branch could be `first-action`_.
- On the new branch, create a directory: `action-a`. _Note:_ If you're working on GitHub.com, you can create a directory and a file at the same time by naming the file `action-a/Dockerfile`.
- In the `action-a` directory, create a file titled `Dockerfile`.
- Create a new branch. _Branches should be named intentionally, so a good name for this branch could be `first-action`_.
- On the new branch, create a directory: `action-a`. _Note:_ If you're working on GitHub.com, you can create a directory and a file at the same time by naming the file `action-a/Dockerfile`.
- In the `action-a` directory, create a file titled `Dockerfile`.
1. Fill the `Dockerfile` with the content below:
```Dockerfile
FROM debian:9.5-slim

LABEL "com.github.actions.name"="Hello World"
LABEL "com.github.actions.description"="Write arguments to the standard output"
LABEL "com.github.actions.icon"="mic"
LABEL "com.github.actions.color"="purple"

LABEL "repository"="http://github.com/octocat/hello-world"
LABEL "homepage"="http://github.com/actions"
LABEL "maintainer"="Octocat <octocat@github.com>"

ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
```

```Dockerfile
FROM debian:9.5-slim

ADD entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
```

1. Commit your file
- If you're working locally, you will also need stage your file and to push the branch to GitHub.
- If you're working locally, you will also need stage your file and to push the branch to GitHub.
1. Open a pull request with your new branch against `master`
<hr>
Expand Down
Loading

0 comments on commit ac0d62b

Please sign in to comment.