Skip to content

Latest commit

 

History

History
154 lines (144 loc) · 4.11 KB

lab02.md

File metadata and controls

154 lines (144 loc) · 4.11 KB

2 - Workflow Syntax

In this lab you will update the workflow syntax.

Duration: 5-10 minutes

References:

2.1 Add new jobs with dependencies

  1. Open the workflow file job-dependencies.yml
  2. Edit the file and copy the following YAML content at the end of the file:
  build:
    runs-on: windows-latest
    steps:
      - run: echo "This job will be run in parallel with the initial job."
  test:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - run: echo "This job will be run after the build job."
  ring01:
    runs-on: ubuntu-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring02:
    runs-on: macos-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring03:
    runs-on: ubuntu-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring04:
    runs-on: ubuntu-latest
    needs: [ring01,ring02,ring03]
    steps:
      - run: echo "This job will be run after the ring01,ring02,ring03 jobs."
  prod:
    runs-on: ubuntu-latest
    needs: [ring04]
    steps:
      - run: echo "This job will be run after the ring04 job."
  1. Commit the changes into the main branch
  2. Go to Actions and manually trigger the workflow by clicking on Run Workflow button
  3. See the details of your running workflow

2.2 Create a matrix build

  1. Using the same file as step 2.1, copy the following YAML content and replace the build job
  build:
    runs-on: ubuntu-latest  
    strategy:
      matrix:
        configuration: [debug, release]
    steps:
    - run: echo "This job builds the cofiguration ${{ matrix.configuration }}."
  1. Update the workflow to run on push events
on:
  workflow_dispatch:
  push:
    branches:
      - main
  1. Commit the changes into the main branch
  2. Go to Actions and see the details of your running workflow

2.3 Final

job-dependencies.yml
name: 02-2. Dependencies 

on:
  workflow_dispatch:
  push:
    branches:
      - main
    
jobs:
  initial:
    runs-on: ubuntu-latest
    steps:
      - run: echo "This job will be run first."
  fanout1:
    runs-on: ubuntu-latest
    needs: initial
    steps:
      - run: echo "This job will run after the initial job, in parallel with fanout2."
  fanout2:
    runs-on: ubuntu-latest
    needs: initial
    steps:
      - run: echo "This job will run after the initial job, in parallel with fanout1."
  fanout3:
    runs-on: ubuntu-latest
    needs: fanout1
    steps:
      - run: echo "This job will run after the initial job, in parallel with fanout2."
  fanin:
    runs-on: ubuntu-latest
    needs: [fanout1, fanout2]
    steps:
      - run: echo "This job will run after fanout1 and fanout2 have finished."
  build:
    runs-on: ubuntu-latest  
    strategy:
      matrix:
        configuration: [debug, release]
    steps:
    - run: echo "This job builds the cofiguration ${{ matrix.configuration }}."
  test:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - run: echo "This job will be run after the build job."
  ring01:
    runs-on: ubuntu-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring02:
    runs-on: macos-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring03:
    runs-on: ubuntu-latest
    needs: test
    steps:
      - run: echo "This job will be run after the test job."
  ring04:
    runs-on: ubuntu-latest
    needs: [ring01,ring02,ring03]
    steps:
      - run: echo "This job will be run after the ring01,ring02,ring03 jobs."
  prod:
    runs-on: ubuntu-latest
    needs: [ring04]
    steps:
      - run: echo "This job will be run after the ring04 job."