Skip to content

Instantly share code, notes, and snippets.

@HarshadRanganathan
Last active June 3, 2023 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarshadRanganathan/5bf32fca000954cc43d25c1f5d897195 to your computer and use it in GitHub Desktop.
Save HarshadRanganathan/5bf32fca000954cc43d25c1f5d897195 to your computer and use it in GitHub Desktop.
Github Actions Notes
  • Context variables - availability varies based on workflow step

    • github e.g. ${{ github.actor }}
    • env
    • vars
    • job, jobs
    • steps
    • runner
    • secrets
    • strategy
    • matrix
    • needs
    • inputs
  • Triggers

    • Events
    • Manual
    • Filters
    • Schedule ...
  • Define Actions used in workflow

    • Same repo as the workflow file e.g. {owner}/{repo}@{ref} or ./path/to/dir syntax
    • Any public repo e.g. {owner}/{repo}@{ref}
    • Docker Image e.g. docker://{image}:{tag}
    • Refs can be - tags, SHAs, branches
  • Inputs & Outputs

  • Environment variables using env:

  • Scripts using run: - command or script location e.g. ./.github/scripts/build.sh

  • Conditions

    • if e.g. if: ${{ <expression> }}
  • Functions

    • contains( search, item ), contains(github.event.issue.labels.*.name, 'bug'), contains(fromJSON('["push", "pull_request"]'), github.event_name)
    • startsWith( searchString, searchValue )
    • endsWith( searchString, searchValue )
    • format( string, replaceValue0, replaceValue1, ..., replaceValueN)
    • join( array, optionalSeparator )
    • toJSON(value)
    • fromJSON(value)
    • Status checks
      • if: ${{ success() }}
      • if: ${{ cancelled() }}
      • if: ${{ failure() }}
  • Pass Values

    • Job to Job - use job output
    • Between steps in a Job - use env var & GITHUB_ENV file
  • Job dependency - needs

  • Cache dependencies

  • Workflow commands

    • echo "::debug::Set the Octocat variable"
    • group log lines ::group::{title}::endgroup::
  • Starter Workflows

  • Reusing Workflows

    • Called Workflow workflow_call:, inputs, secrets
    • Caller Workflow uses, with
  • Cache dependencies

  • Jobs

    • Run on containers
  • Service Containers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment