diff --git a/.github/steps/-step.txt b/.github/steps/-step.txt index 0cfbf08..00750ed 100644 --- a/.github/steps/-step.txt +++ b/.github/steps/-step.txt @@ -1 +1 @@ -2 +3 diff --git a/README.md b/README.md index 81cfcca..294a4c5 100644 --- a/README.md +++ b/README.md @@ -14,30 +14,22 @@ _Create a GitHub Action and use it in a workflow._ -## Step 2: Add a job to your workflow file +## Step 3: Add actions to your workflow file -_Nice work! :tada: You added a workflow file!_ +_Nice work adding a job to your workflow! :dancer:_ -Here's what it means: +Workflows have jobs, and jobs have steps. So now we'll add steps to your workflow. -- `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 repository -- `pull-requests: write` gives the workflow permission to write to pull requests. This is needed to create the welcome comment. +**What are _steps_?**: Actions steps will run during our job in order. Each step is either a shell script that will be executed, or an action that will be run. Each step must pass for the next step to run. Actions steps can be used from within the same repository, from any other public repository, or from a published Docker container image. -Next, we need to specify jobs to run. +In our action, we post a comment on the pull request using a [bash](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) script and [GitHub CLI](https://cli.github.com/). -**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](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#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](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions#understanding-the-workflow-file)" article. - -### :keyboard: Activity: Add a job to your workflow file +### :keyboard: Activity: Add Actions steps to your workflow file 1. Open your `welcome.yml` file. 2. Update the contents of the file to: @@ -52,6 +44,11 @@ In this step of our exercise, we will add a "build" job. We will specify `ubuntu build: name: Post welcome comment runs-on: ubuntu-latest + steps: + - run: gh pr comment $PR_URL --body "Welcome to the repository!" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} ``` 3. Click **Start commit** in the top right of the workflow editor. 4. Type your commit message and commit your changes directly to your branch.