Ben Chuanlong Du's Blog

It is never too late to learn.

Tips on GitHub Actions

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tips and Traps

  1. You can use sudo without password in Linux and macOS when running GitHub Actions.

  2. GitHub Actions supports manual triggers with workflow_dispatch. Workflow parameters are supported in manually triggers.

  3. GITHUB_TOKEN is an automatically generated secret that lets you make authenticated calls to the GitHub API in your workflow runs. Actions generates a new token for each job and expires the token when a job completes. GITHUB_TOKEN can also be used for the GitHub Action peter-evans/create-pull-request to create PRs automatically. However, GitHub bot is the owner of a PR created by the GitHub action create-pull-request with GITHUB_TOKEN which might have issues triggering other pipelines listening to PR events. A simple solution to this problem is to manually create a repository secret (e.g., GITHUBACTIONS) and use it to autenticate the GitHub Action create-pull-request with GITHUB_TOKEN .

  4. Rust cannot be installed into a global location following instructions at Install Rust Globally in Linux . This might because GitHub Actions VMs have restrictions on environemnt variables. You can still install Rust using root (via sudo) but this doesn't give you much priviledge as the root account in a GitHub Actions VM is restricted too.

  5. OS: ubuntu-latest, windows-latest, macOS-latest

  6. Good practices for GitHub repository with GitHub Actions workflows:

    • Have 2 protected branches main and dev, where main is reserved for releasing and dev is reserved for development.
    • Fork the dev branch for development.
    • A PR from dev to main should be made when it is ready to release a new version.

Branch Matching

on:
push:
    branches:    
    - '*'         # matches every branch that doesn't contain a '/'
    - '*/*'       # matches every branch containing a single '/'
    - '**'        # matches every branch
    - '!master'   # excludes master

For more discussions, please refer to GitHub Actions: how to target all branches EXCEPT master? and Workflow syntax for GitHub Actions .

Good Github Actions

checkout

ssh-agent

ssh-agent is a GitHub Action to setup ssh-agent with a private key.

bencher

Bencher is a suite of continuous benchmarking tools.

GitHub Actions for Python

https://hynek.me/articles/python-github-actions/

https://github.com/actions/setup-python

Pull Request

https://github.com/peter-evans/create-pull-request

Create PR from push on a given branch

Examples

Using semantic-release with GitHub Actions

automerge-action

Automatic Deployment With Github Actions

Zip Code Base with Github Actions for Releases

GitHub Automatic Releases

Introducing GitHub Package Registry

References

Comments