github actions reusable workflow example

To create a template or reusable workflow, we probably need to understand how to 

1. create the template

2. call or use the template 


In this example, we will create a pipeline that does some fake pre-requisite thing and then perform dotnet build. 


Creating the template

To create the template that accepts some input, you can use this example here. Notice how we use the input variables.

// dotnet-workflow.yaml

on:
 workflow_call:
   inputs:
      message:
        type: string
        required: true
      message2:
        type: string


jobs:
  build:
    runs-on: ubuntu-latest

    steps:

      - name: build dotnet
        run: |
            echo ${{ inputs.message }}
            echo ${{ inputs.message2 }}



To use/apply this template from the pipeline, under the job call prerequisite, we uses dotnet-workflow.yaml that is defined in a branch called "feat/template-resable-workflow".

 

name: dotnet package

on: [push]

jobs:
  prerequisite:
    uses: mitzenjeremywoo/githubaction_work/.github/workflows/dotnet-workflow.yaml@
feat/template-resable-workflow
    with:
       message: "message1"
       message2: "message2"

    




 



Comments

Popular posts from this blog

The specified initialization vector (IV) does not match the block size for this algorithm