githubuniverseworkshops/GitHub-Actions-Planet-GitHubUniverse2021

Hello, GitHub Actions continent

bryantson opened this issue · 1 comments

Welcome to Hello, GitHub Actions continent

1_HelloGitHubActions

The god of this planet wants your journey to be useful and pleasant one. However, it is still nice to give a proper thanks to this planet...

Your mission

  • Learn about GitHub Actions
  • Activity - Let's create your first GitHub Actions

Learn about GitHub Actions

GitHub Actions 101

GitHub Actions is a GitHub product that allows you to automate your workflows.

image

  • Workflows stored as yml files
  • Fully integrated with GitHub
  • Respond to GitHub events
  • Live logs and visualized workflow execution
  • Community-powered workflows
  • GitHub-hosted or self-hosted runners
  • Built-in secret store

GitHub Actions Marketplace

image

  • Discover open-source Actions across multiple domains
  • ~10,000 Actions (and counting...)
  • Verified creators
  • Reference these Actions directly in your workflow
  • Integrated into the GitHub editor

High level architecture of GitHub Actions

image

Basic syntax

# Defines the name
name: Super Linter Workflow

# Event that will get triggered. In this case, it gets triggered by push event
on:
  push:

# Different jobs can be defined
jobs:
  # Name of job
  lint:
     # Name of this job
     name: Lint Code Base

     # Type of runner. In this case, it is a default GitHub Actions runner
     runs-on: ubuntu-latest

     # You can define different steps
     steps:
        # First, checkout the code from the repo
        - uses: actions/checkout@v2
        # Uses the super-linter from GitHub Action plugin
        - uses: github/super-linter@v3
           env:
              # GitHub secret value can be used
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Let's create your first GitHub Actions

You need to create a GitHub Actions to say a proper greeting with a message:

Thank you for warm welcoming! My name is xxx
I will enjoy my time in this wonderful GitHub Actions planet!

To do this you need to do the following steps:

  1. Copy the scripts below and save into your note
  2. Create a branch named hello-username where username is your GitHub username
  3. Go to .github/workflows directory and click Add file. Type in following format action-hello-username.yml where you will replace username with your own GitHub username. Save the file by commiting to the directory.
  4. Make a Pull Request to the main branch
  5. Somebody will approve the workflow.
  6. You can then run your workflow
# Change this line with username with your GitHub username
name: Hello from @username

on:
  workflow_dispatch:
      inputs:
         myName:
            description: "Please type in your name"
            required: true
            default: ''

jobs:
   Hello-GitHub-Actions:
      runs-on: ubuntu-latest
      name: Just saying "hi"

      steps:
        - name: Hello, GitHub Actions planet
          run: |
             echo "Thank you for warm welcoming! My name is ${{ github.event.inputs.myName }}"
             echo "I will enjoy my time in this wonderful GitHub Actions planet!"

⏭️ After you are done, you can close this issue to move forward to next one.

Congratulation. You are done with Hello, GitHub Actions continent

image

Let's move to the next issue