Skip to content

GitHub Actions quickstart and reference for myself. Perhaps it will be helpful to others.

License

Notifications You must be signed in to change notification settings

chingc/tutorial-github-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Actions

A collection of GitHub Actions workflows demonstrating various capabilities and features.

basic.yml

A basic workflow to do the essentials.


If you're unfamiliar with GitHub Actions this will help you get started quickly.

.github/workflows/basic.yml

  • Runs when changes are pushed
  • Runs on a schedule
  • Can be run manually from the GitHub UI
  • Uses actions/checkout
  • Uses actions/setup-python with pip cache
  • Installs requirements.txt and runs a simple test
  • Includes dependabot.yml to automatically check for package updates

branch_name.yml

Getting the branch name.


This is a common CI operation. Surprisingly, there's no pre-defined way to get it in GitHub Actions.

This demo shows the simplest way without using 3rd party actions or other tools.

It works in most cases, but there are some quirks.

For example, if your commit is tagged this method will return the tag instead of the branch name. See SO link in the references for details.

You may also get an unexpected result depending on the event that triggered the workflow. This demo is set to trigger on pull_request and on push to illustrate this behavior.

.github/workflows/branch_name.yml

  • Shows various github context properties that may or may not contain the branch name
  • Sets branch name to the top level env so it can be accessed by the entire workflow

context.yml

Accessing information about workflow runs.


This can be helpful for debugging workflow errors or bugs, but be careful as it has the potential to output sensitive information.

.github/workflows/context.yml

  • Shows various contexts

env_var.yml

Working with environment variables.


Environment variables and their scopes work as you'd expect in GitHub Actions.

They're also fairly self-contained, so any changes you make are isolated to the job you're in.

One quirk that can cause confusion is the fact that environment variables defined within a step aren't accessible until the next step.

.github/workflows/env_var.yml

  • Read env vars
  • Write env vars
  • Pass env vars

github_script.yml

Using javascript in your workflow.


GitHub provides an action that lets you easily write javascript directly in your workflow.

The action also includes an object with the current workflow context, references to other useful packages, and it's a pre-authenticated octokit/rest.js client.

.github/workflows/github_script.yml

homebrew.yml

Using homebrew in your workflow.


Leverage the convenience of homebrew to install applications on GitHub Actions runners.

.github/workflows/homebrew.yml

system_path.yml

Working with the PATH environment variable.


Read, write, and modify PATH like any other environment variable.

.github/workflows/system_path.yml

  • Modify PATH env var

References

About

GitHub Actions quickstart and reference for myself. Perhaps it will be helpful to others.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages