Workflow file syntax
    • PDF

    Workflow file syntax

    • PDF

    Article Summary

    Background

    These two “Hello World” workflow demos will show the basics of a workflow file.

    Hello World minimal

    The first demo shows the minimum workflow to print “Hello World”.

    https://hub.allspice.io/Actions-demos/.allspice/workflows/00-Hello-world-minimal.yml

    name: Workflow-hello-world
    
    on: 
      push:
      issues:
        # Trigger on issue open, close, or reopen
        types: [opened, closed, reopened]
    
    jobs:
      Job-Hello-World:
        runs-on: ubuntu-latest
        steps:
          - name: "Print Hello World 🔎" 
            run: echo "Hello World"      


    Hello World with comments

    The second demo shows a minimal workflow, but with comments to explain each part of the YAML file.

    https://hub.allspice.io/Actions-demos/.allspice/workflows/01-Hello-world-commented.yml

    
    # This is a basic workflow to help you get started with Actions
    # Lines beginning with a `#` are comments, and only intended to help reviewers understand the script
    # Actions documentation: https://learn.allspice.io/docs/actions-cicd
    # This file is written in YAML syntax, to learn more about YAML visit https://learn.allspice.io/docs/yaml
    
    # Workflow name
    name: Hello-world-commented
    
    # Workflow triggers on
    # To learn more about triggers, visit https://learn.allspice.io/docs/actions-triggers
    on: 
      # Workflow is triggered if any of the following events occur
      # i.e. Logical OR of triggers, i.e. trigger on push or issues
    
      # Trigger on push
      push:
    
      # Trigger on issues
      issues:
        # Trigger on issue open, close, or reopen
        types: [opened, closed, reopened]
    
    
    # Workflow jobs
    # Jobs run in parallel by default
    # To run jobs in sequence, create multiple steps in a job
    jobs:
    
      # Job name
      Job-Hello-World:
        
        # Set up server container using Ubuntu operating system (Debian based Linux distribution)
        # To learn more about Ubuntu, visit https://ubuntu.com/
        runs-on: ubuntu-latest
    
        # Job steps
        # Steps run in sequence on the runner machine
        # To make steps run in parallel, create multiple jobs
        steps:
    
          # Job steps start with - name: "Step name"
          - name: "Print Hello World 🔎" 
            
            # run keyword specifies the shell command to run
            # The shell command is a simple echo command to print "Hello World"
            # The command is run in the runner machine
            # To learn more about shell commands, visit https://www.shellscript.sh/
            run: echo "Hello World"
    
          - name: "Multiline shell command 🔎"
            
            # The shell command is a simple echo command to print two lines of text
            # The | pipe character is used to specify a multiline command
            run: |
              echo "This is the first line"
              echo "This is the second line"


    Running the demos

    To run the demos:

    • Migrate actions demo to new repo

    • Enable actions in repo

    • Trigger repo

    • Visit repo Actions tab

    • Click on workflows

    • View the results

    Here are step-by-step instructions

    Migrate Actions demo repo

    Click the + button in the upper right corner, next to your profile, and select New Migration

    image.png

    Select AllSpice

    image.png

    Paste https://hub.allspice.io/AllSpice-demos/Actions-demo.git into Migrate / Clone From ULR Field

    Make sure you select an organization as owner
    Personal repos are not currently enabled in this phase.

    Click Migrate Repository
    image.png

    You should see your new repository.

    Enable actions in your repository

    Enable actions by visiting your repository->🔧Settings, and clicking [X] Enable Repository Actions

    image.png

    Scroll down to search (ctrl+f) for "Actions"

    Ensure Enable Repository Actions is checked

    image.png

    enable actions in your repository.gif

    Actions are only for organization repos
    Actions will not currently work on a personal repositories during this phase of the beta. You must use a repository owned by an organization.

    Trigger repo workflows

    To trigger these workflows, create a new issue.

    Visit your Actions tab

    Click on your repository Actions tab to view a list of all workflows.

    actions tab.png

    Click on your workflow

    Click on your Action run to view the results. The title is the same as the commit message of your most recent push.

    click on your workflow title.png

    View the results

    Click on the job steps to see Hello World


    If you’re having issues, don’t hesitate to ask for help at support@allspice.io

    Next

    Actions demo - Generate a BOM with a re-usable action


    Was this article helpful?