Create a GitHub Action and use it in a workflow.
Nice work! 🎉 You added a workflow file!
Here's what it means:
name: Post welcome comment
gives your workflow a name. This name appears on any pull request or in the Actions tab of your repository.on: pull_request: types: [opened]
indicates that your workflow will execute anytime a pull request opens in your repository.permissions
assigns the workflow permissions to operate on the repositorypull-requests: write
gives the workflow permission to write to pull requests. This is needed to create the welcome comment.
Next, we need to specify jobs to run.
What is a job?: A job is a set of steps in a workflow that execute on the same runner (a runner is a server that runs your workflows when triggered). Workflows have jobs, and jobs have steps. Steps are executed in order and are dependent on each other. We'll add steps in the next step of this exercise. To read more about jobs, see "Jobs".
In this step of our exercise, we will add a "build" job. We will specify ubuntu-latest
as the fastest and cheapest job runner available. If you want to read more about why we'll use that runner, see the code explanation for the line runs-on: ubuntu-latest
in the "Understanding the workflow file" article.
- Open your
welcome.yml
file. - Update the contents of the file to:
name: Post welcome comment on: pull_request: types: [opened] permissions: pull-requests: write jobs: build: name: Post welcome comment runs-on: ubuntu-latest
- Click Start commit in the top right of the workflow editor.
- Type your commit message and commit your changes directly to your branch.
- Wait about 20 seconds for actions to run, then refresh this page (the one you're following instructions from) and an action will automatically close this step and open the next one.
Get help: Post in our discussion board • Review the GitHub status page
© 2023 GitHub • Code of Conduct • MIT License