Skip to content

Latest commit

 

History

History
114 lines (90 loc) · 4.92 KB

3-firstactionworkflow.md

File metadata and controls

114 lines (90 loc) · 4.92 KB

3. Creating your first Action Workflow

Objectives of this hands-on lab

In this hands-on lab your will create your first GitHub Action Workflow and learn how you can use Actions to automate tasks in your software development lifecycle. If you like more background information, please refer to the GitHub Actions pages on GitHub Docs. Good luck! 👍

Before you start with this lab, please remove the branch rule, so you can commit to the main branch without a pull request to speed up the process 😏.

Workflow execution example

This hands on lab consists of the following steps:

3.1 Creating the workflow

  1. Work inside your current repository Microsoft-Bootcamp/attendee-<your-github-handle>
  2. Create a .github/workflows directory in your repository on GitHub if this directory does not already exist.
  3. In the .github/workflows directory, create a file named github-actions-demo.yml.
  4. Copy the following YAML contents into the github-actions-demo.yml file:
name: GitHub Actions Demo
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v2
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "🍏 This job's status is ${{ job.status }}."
  1. Scroll to the bottom of the page and select Create a new branch for this commit and start a pull request. Then, to create a pull request, click Propose new file.

Committing the workflow file to a branch in your repository triggers the push event and runs your workflow.

3.2 Viewing your workflow results

  1. On GitHub, navigate to the main page of the repository.

  2. Under your repository name, click Actions.

  3. In the left sidebar, click the workflow you want to see.

  4. From the list of workflow runs, click the name of the run you want to see.

  5. Under Jobs , click the Explore-GitHub-Actions job.

  6. The log shows you how each of the steps was processed. Expand any of the steps to view its details.

For example, you can see the list of files in your repository:

If time permits: Only trigger workflow when a change is made to the website

See: Workflow syntax for github actions - on push/pull - request paths.

name: GitHub Actions Demo
on:
  push:
    paths:
    - 'TailwindTraders.Website/**/*'
jobs:

...
...

If time permits: Only trigger workflow on new issue created

See: Webhook events and payloads - Issues

...
...

on:
  issues:
    types: [opened]

...
...

If time permits: Create a Matrix build for release and debug

See: Workflow Syntax - Jobs - Matrix Strategy

...
...

Explore-GitHub-Actions:
    runs-on: ubuntu-latest  
    strategy:
      matrix:
        configuration: [debug, release]
    steps:
    - run: echo "🔧 Building the cofiguration ${{ matrix.configuration }}."

...
...