Skip to content

palexcast/github-actions-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to the GitHub Actions workshop!

You will only be required to change code in the folder .github/workflows for the first few tasks.

Tasks

Task 1 - Fix the broken workflow

File: .github/workflows/task_1_broken.yml

  1. The workflow is broken. Fix it.

When it is working you should see a green checkmark in the GitHub Actions status beside the action Task 1 - Fix the broken workflow

Look at the error message in the GitHub Actions log to discover what is wrong. Often GitHub Actions will indicate syntax errors in the workflow file.

Task 2 - Optimize the workflow

File: .github/workflows/task_2_optimize.yml

  1. Copy the contents of your finished task 1 workflow file into this file.

  2. Change the name to Task 2 - Optimizing the workflow

We won't be updating the workflow to be more performant as in terms of cost, but in terms of visibility.

The workflow will exit at the earliest failure, so it will not run all steps, hiding some errors.

We want there to be three jobs, Lint, Test and Build.

This way, if there are any errors in each of the steps, it will be quick to discover what went wrong.

Task 3 - Creating a workflow Chuck Norris would be proud of

File: .github/workflows/task_3_quote_of_the_day.yml

  1. Create a new workflow file named task_3_quote_of_the_day.yml

  2. This workflow should trigger on the event workflow_dispatch, read more here.

  3. Setup a new job that uses these steps to output a Chuck Norris Joke.

      - name: Fetch quote
        uses: fjogeleit/http-request-action@v1
        id: getQuoteResponse
        with:
          url: 'https://api.chucknorris.io/jokes/random'
          method: 'GET'
      - name: Show Response
        id: quote
        run: |
          echo "::set-output name=QUOTE::${{ fromJson(steps.getQuoteResponse.outputs.response).value }}"
  1. Use this action to perform a http POST request to https://chuck.alexc.no/api/quote. The body should be as follows
{ "quote": "<the quote here>", "accessCode": "<ask Alex for the code>" }

The accessCode is secret, and should be treated as such! See this link for information on how to create a secret and this link on how to use a secret in your workflow.

The quote can be fetched from the step with id: quote, look here for more info.

  1. View the glorious results here.

We won't be updating the workflow to be more performant as in terms of cost, but in terms of visibility.

The workflow will exit at the earliest failure, so it will not run all steps, hiding some errors.

We want there to be three jobs, Lint, Test and Build.

This way, if there are any errors in each of the steps, it will be quick to discover what went wrong.

Task 4 - Create a composite action

File: .github/workflows/task_4_composite_action.yml

  1. Create a new workflow file named task_4_composite_action.yml
  2. Create a composite action locally, following these instructions
  3. The action should take an input accessCode and perform the same steps as the previous task with this input.
  4. Edit the workflow task_4_composite_action.yml so that it uses your new action!

Task 5 - Create your own workflow that listens to the issue comment event

Use the marketplace to find actions that help you respond to comments. Try to make it react with an emoji, or respond to the comment with a message.

Task 6 - Creating a ChatOps Bot

You can dispatch your own repository events in GitHub Actions. These can be useful to trigger other workflows who are listening to the same event.

Use this repository as inspiration to get started. https://github.com/peter-evans/slash-command-dispatch

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published