Skip to content

Latest commit

 

History

History
118 lines (78 loc) · 4.24 KB

setup.md

File metadata and controls

118 lines (78 loc) · 4.24 KB

Github Actions Katas

This series of katas will go through the basic steps in github actions, making you able to make CI builds in the end.

Learning Goals

  • Creating an instance of the template repository
  • Creating a workflow file

Building a CI pipeline in GitHub Actions

In this workshop we will be using a small java service which uses Gradle to build the application.

The application is found in the app directory, though the details of the implementation are not interesting for the purposes of these katas. There are a number of shell scripts that help with building the application, these are located in the ci directory.

The purpose of these katas is to use the small java application to exemplify how to use Github Actions to build, test and package your applications.

We ultimately want a pipeline that has the following jobs:

We are not going to do it all in one go, but rather step by step.

Exercise

Overview

In this exercise we are creating your own instance of this templated repository, and creating a workflow file called .github/workflows/hello-world.yml.

💡 This requires git email and name to bee configured on your machine. If you have not done this, here are the commands to set it up

You need to provide your email and name to git with the following commands.

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

Tasks

Creating a repository

  • Go to Code tab of this repository and click Use this template

Use this template

  • Select your GitHub user as the owner and name the repository. Leave the repo public to have unlimited action minutes.

💡 From now on only use the your own repository.

Creating the workflow

All your workflow files will be located in the .github/workflows folder.

  • Click on the Actions tab and click New workflow

  • Click on the "setup the workflow yourself" link

hello-world

  • The file should look like this:
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Hello, world!

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
  • click Commit changes and commit to the main branch
  • Go to the Actions tab and see the workflow running
  • Click on the workflow and see the output of the workflow

Summary

Congratulations! You have now created your first workflow! It does not do much, but in the next exercise we will start building on it.