Closed geored closed 3 years ago
Error The title of this pull request isn't what I expected!
Solution Verify the name of your pull request is Create a workflow and keep in mind that this is case-sensitive.
Follow these steps to rename your pull request:
I'll respond when I detect this pull request has been renamed.
Uh oh, I expected a file that I didn't find. Please make sure there is a file at the path: .github/workflows/my-workflow.yml
.
I'll respond when I detect a new commit on this branch.
Great job adding the workflow. Adding that file to this branch is enough for GitHub Actions to begin running on your repository. The time this takes will vary based on the complexity of the workflow. While this runs I'll briefly explain the components of the workflow you just added.
If you want to inspect your running workflow you can do so by heading over to the Actions tab of this repository.
GitHub Actions is a unique world that lives alongside your repository. It is one made up of many moving parts and having a general understanding of these parts will help us understand the behavior we are going to program into our action.
From 30,000 feet GitHub Actions is made up of the following components, with each component having its own complexities:
Component | Description |
---|---|
Action | Individual tasks that you combine as steps to create a job. Actions are the smallest portable building block of a workflow. To use an action in a workflow, you must include it as a step. |
Artifact | Artifacts are the files created when you build and test your code. Artifacts might include binary or package files, test results, screenshots, or log files. Artifacts can be used by the other jobs in the workflow or deployed directly by the workflow. |
Event | A specific activity that triggers a workflow run. |
Job | A defined task made up of steps. Each job is run in a fresh instance of the virtual environment. Jobs can run at the same time in parallel or be dependent on the status of a previous job and run sequentially. |
Runner | Any machine with the GitHub Actions runner application installed. You can use a runner hosted by GitHub or host your own runner. A runner waits for available jobs. Runners run one job at a time reporting the progress, logs, and final result back to GitHub. |
Step | A step is a set of tasks performed by a job. Steps can run commands or actions. |
Virtual Environment | The virtual environment of a GitHub-hosted runner includes the virtual machine's hardware configuration, operating system, and installed software. |
Workflow | A configurable automated process that you can set up in your repository. Workflows are made up of one or more jobs and can be scheduled or activated by an event. |
When a repository is configured with a workflow file, like we just created, the following series of events occurs.
I'm glad you asked. Let's take a look at a workflow file similar to what we just committed to this repository.
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run a one-line script
run: echo Hello, world!
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
This file is made up of a series of metadata, as well as behaviors that we wish to happen when the workflow is triggered.
Let's take a second to talk about each of the pieces that we see here:
name: CI
CI
on: [push]
Jobs:
build
runs-on: ubuntu-latest
uses: actions/checkout@v1
name: Run a one-line script
run: echo Hello, world!
name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
๐Take a deeper dive into workflow components ๐Read more about configuring workflows
if you don't see a response from me below this, try making a new commit to this branch. Your workflow may have finished before I was ready to listen
Our workflow has finished so let's take a look at the results now that we have learned a little bit about workflows while we waited.
In the left-hand panel of this screen you can see that this workflow, named CI
was triggered on: push
and ran the job titled build
.
The right-hand panel shows real-time logging of the steps executed by the build
job. There are currently 5 steps defined for this job:
๐คThis is interesting, in the my-workflow.yml
file we defined 3 steps, not 5, so what happened?
GitHub Actions will always add the Set up job
and Complete job
steps to each job in a workflow. These steps are what configure the virtual environment before running your steps and shut it down properly before moving onto the next job in your workflow.
If you recall, we had 1 step that used an action and 2 steps that ran commands, can you identify which step used the action?
If you want to see this for yourself head over to your [Actions tab]() and examine the workflow named CI
Currently my-workflow.yml
is not set up correctly for our use-case. It worked great for allowing us to take a high-level look at workflows, but if we want to use our custom actions there are some changes that we have to make to it.
Edit the my-workflow.yml
to have the following contents:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
I'll respond in this pull request once you make these changes.
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
name: JS Actions
I'll respond when I detect a new commit on this branch.
Got:
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |
echo Add other actions to build,
echo test, and deploy your project.
@geored you're doing great so far ๐! You've had to do a lot of workflow set up so we can begin writing custom actions. We have just one more thing to add to our my-workflow.yml
file before we get to the action side of things.
Before we make our final workflow change let's do a quick recap about what we've done.
Action | Key Takeaways |
---|---|
Created my-workflow.yml inside of .github/workflows directory |
GitHub repositories look in the .github/workflows folder for workflow files. |
Used a templated workflow | GitHub provides many templates for workflow files. This is a great spot to look when setting up a new workflow. If you can't find what you are looking for, you can always click the setup a workflow yourself button for a minimal starter template |
Workflow environment | You learned, from a high level, how a repository uses a workflow file to run commands or actions based on triggers. You also learned that where these commands or actions execute is something that can be specified |
Workflow syntax | You were briefly introduced to the workflow YAML syntax. |
If that seems like a lot of things just to get started... well, it is! GitHub Actions is a robust platform designed to automate a wide range of tasks for your repositories.
If you'd like to see more examples of workflows and actions then check out these Learning Lab courses all about GitHub Actions:
Edit the my-workflow.yml
to contain the following:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I notice you've made these changes
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: hello action
- uses: ./.github/actions/hello-world
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: hello action
- uses: ./.github/actions/hello-world
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- name: Checkout
- uses: actions/checkout@v1
- name: hello action
- uses: ./.github/actions/hello-world
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: hello action
uses: ./.github/actions/hello-world
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: hello action
uses: ./.github/actions/hello-world
Uh oh, I'm specifically looking to see whether .github/workflows/my-workflow.yml
contains the following code:
- name: hello-action
uses: ./.github/actions/hello-world
I'll respond when I detect a new commit on this branch.
Got:
name: JS Actions
on: [push]
jobs:
action:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: hello action
uses: ./.github/actions/hello-world
Initial Workflow