See how Action attributes are used to fill out a configuration and help with code reuse.
- [Instructor] Now that we've created a work flow, and added an action, we can get more familiar with the attributes that define an action. I'm on the actions tab, displaying the action we just created. I can open the workflow editor by clicking the link to the workflow file here. To edit this workflow, I click the pencil icon here on the top right side of the editor. Now I'll go to full screen to open the editor up a bit more. Now I can open our first action by clicking edit on the bottom of the action tile. This opens up the configure action dialogue on the right, which is the same dialogue we use to create the action. Each of the fields on the dialogue is an attribute that configures the action. The first attribute is probably the most important. The uses attribute defines the docker image that will run the action. In this case, we're using the docker command line interface image. The string of characters after the at sign is the commit hash identifying the version of the image that we used. Next up is the label attribute. This is also an important attribute, because it names our action. Each action that belongs to a workflow must have a unique label. If we try to create two actions in this workflow, and gave them the same name, we would get an error. Next, we come to the runs attribute. This would specify a command to run inside the docker image. We didn't enter anything here because typically an action will already have a command that it will run by default. There may be actions that run docker images without commands, but for the most part, actions will also use docker images and configurations that fulfill some specific task. After runs, we find the args attribute. This is where we define the arguments that get passed to the action. In most cases, these arguments will be passed to the command that the action runs by default inside the docker image. Arguments can be passed in as a list or as a string. In this case, we used a string. As arguments are passed in, they are turned into a list by splitting the string on wide space. Any arguments that have spaces need to be surrounded by quotes. Next, we have the secrets attribute. This lets us inject secret values into the action as encrypted environment variables. One secret, a get hub token, is automatically made available for each action. To use it, we would click the checkbox next to it. The last attribute in the list is the ENV attribute for adding environment variables. Environment variables are also key value pairs that are stored in the action as plain text. Using the visual editor is fine, but there's more than one way to edit an action. We can also use the file editor. In the file editor, we can add or remove attributes by adding or removing text. And if we go to the preview changes tab, we can see anything that was added or removed from the original file. Whether we make changes in the visual editor or the file editor, the preview screen gives us the plain text view of the differences.
Released
5/28/2019- 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
Share this video
Embed this video
Video: Action attributes