hectorsector / actions-workflow

https://github-learning-lab-staging.herokuapp.com/githubtraining/enable-a-workflow-with-github-actions
0 stars 0 forks source link

Add branch cleanup workflow #2

Closed hectorsector closed 5 years ago

ghost commented 5 years ago

Great work! Since this branch cleanup occurs after pull requests are merged, you'll notice we chose the pull_request for the on attribute. Most GitHub events are available as triggers.

Step 2: Add the action block

Let's now add the action block. The action block is where we choose the action we want to use. Actions can be identified in any of the following forms:

For this example, we'll use the branch cleanup action. Because this is an action in a public GitHub repository, we'll refer to it using the syntax: jessfraz/branch-cleanup-action@master, which tells us to use an action in the repository jessfraz/branch-cleanup-action, and to specifically pick the version of the action on the master branch.

This action's purpose is to delete a branch when it is merged. To do this, the action needs access to the repository on which it is installed. In this step, we'll allow the action access to our repository by giving it access to GITHUB_TOKEN, an encrypted token that allows the action to perform certain functions in this repository.

:keyboard: Activity: Use the branch cleanup action

  1. Click on the Files changed tab of this pull request and edit the main.workflow file.
  2. Drag the connector from the workflow block to the outlined action block for the action
  3. In the Choose action field, type jessfraz/branch-cleanup-action@master
  4. Click Use
  5. In the label field, type branch cleanup
  6. Check the box for :lock: GITHUB_TOKEN in the :lock: secrets section
  7. Click Done
  8. Click Start commit on the top right
  9. Enter a commit message
  10. Select Commit directly to your branch
  11. Click Commit changes

I'll respond below with your next step.

ghost commented 5 years ago

Great! The branch cleanup action is now ready to run. Although we haven't merged this pull request, any change to this pull request triggers the action. The fact that you just committed is one of those possible triggers (it's a pull_request.synchronized event, if you're curious).

Wait for your action to run. You can monitor its progress in the Actions tab.


I'll respond below the branch cleanup action runs.

ghost commented 5 years ago

The action didn't run for some reason. See your actions tab to figure out why.


I'll respond when the action reports another completed run.