Get an introduction to Actions by creating "Hello, World!".
- [Instructor] Let's jump right in and get started with adding an action to a workflow. I've created a new repository and I have the visual workflow editor open. On this screen, I'll follow the directions and click the blue dot to add it to the box below. If you notice, I had to click the actual blue dot. Clicking the arrow won't work. On the right, there's a new dialog for choosing an action. We can look for actions by typing here where it says find or enter an action. For this first action, let's use the GitHub action for Docker. I'll type in docker cli to search for it. That narrows down the search to the action I'm looking for. This action will let me run Docker CLI commands in a prebuilt container environment. Now the window changes a bit with fields that we need to populate with details for our action. For the label, let's change this to my first action. Now I'll scroll down a bit and in the args field, I'll enter run, hello-world. By doing this, we're specifying the arguments that the Docker command line interface will process when this action gets run. In this case, we're asking Docker to run the classic hello world container. Now I'll scroll down to the end of the form and click the done button. That's it. We've created our first action. But we still need to save it. To do that, we click the start commit button. This opens a new form where we can open the details for this commit. For the title of the commit, let's enter create my first action. For now, let's leave the body of the commit blank. We'll keep the default to commit directly to the master branch for now and click commit new file. Okay, we just created our very first workflow in action. To see the results of all that hard work, we need to click back to the actions tab. We may have to wait a minute until our action gets run, so if you get to the actions screen and it still says create a new workflow, don't panic. Just wait a minute or two and refresh the screen. Okay, there's our action. It'll go through a few steps of waiting to run, running, and then when it finishes, it will be indicate if the action succeeded or failed along with a link to a log file. One thing to note is you can't see an action's log file in real time. You have to wait for the action to complete before you can see any output in the log. Looks like things are finished now so I'll click the log file. At the top of the screen, we get some general data for this run. In a few places, we can see that the run succeeded. There's also detail on how much time the action took to run. We can also find the commit that started this run and the branch used for the run. Scrolling down a bit reveals the actual log generated by the action. The first lines we'll see are the output from Docker, as it's building the container environment where the action will run. And if I scroll to the end, we can see the actual output from where Docker ran the hello world container. And at the bottom, the final line of the output is a very gratifying affirmation that our first action was a total success. Now let's discuss some of the details in our action's configuration.
- Creating an action
- Creating a workflow
- Adding actions to a workflow
- Using an action from a repository
- Using environment variables
- Building custom actions
- Use cases for actions and workflows