Write your own GitHub JavaScript Action and automate customized tasks unique to your workflow.
Nice work configuring your action 😄
Every GitHub Action that we write needs to be accompanied by a metadata file. This file has a few rules to it, as are indicated below:
- Filename must be
action.yml
. - Required for both Docker container and JavaScript actions.
- Written in YAML syntax.
This file defines the following information about your action:
Parameter | Description | Required |
---|---|---|
Name | The name of your action. Helps visually identify the actions in a job. | ✅ |
Description | A summary of what your action does. | ✅ |
Inputs | Input parameters allow you to specify data that the action expects to use during runtime. These parameters become environment variables in the runner. | ❌ |
Outputs | Specifies the data that subsequent actions can use later in the workflow after the action that defines these outputs has run. | ❌ |
Runs | The command to run when the action executes. | ✅ |
Branding | You can use a color and Feather icon to create a badge to personalize and distinguish your action in GitHub Marketplace. | ❌ |
Read more about Action metadata
All of the following steps take place inside of the .github/actions/joke-action
directory.
Our action does not require much metadata for it to run correctly. We will not be accepting any inputs, we will however be setting a single output this time.
-
Update the action metadata file
.github/actions/joke-action/action.yml
with the following content:name: "my joke action" description: "use an external API to retrieve and display a joke" outputs: joke-output: description: The resulting joke from the icanhazdadjokes API runs: using: "node16" main: "main.js"
-
Save the
action.yml
file -
Commit the changes and push them to GitHub:
git add action.yml git commit -m 'add metadata for the joke action' git pull git push
-
Wait about 20 seconds then refresh this page (the one you're following instructions from). GitHub Actions will automatically update to the next step.
Get help: Post in our discussion board • Review the GitHub status page
© 2023 GitHub • Code of Conduct • MIT License