Skip to content

Github Action

Create your workflow yml file under .github/workflow. The file name would be the name of the workflow.

Comparison with Gitlab

  • Github Action = Gitlab CICD
  • Github workflow = Gitlab pipeline

Running Environment

  • runs-on specifies VM type
  • container specify docker image

Trigger condition

run on push to master when the file/dir in the included paths are changed

  • use ! to exclude
  • use ** for wildcard
on:
  push:
    branches: [ master ]
    paths:
      - '**.py'
      - 'vue/**'
      - '.github/**'
      - 'static/**'
      - 'templates/**'
      - '.gitignore'
      - '!jetson-nano/**'

Access your repo

Use checkout

jobs:
  myjob:
    steps:
      - uses: actions/checkout@v3

Cache

doc

To make a directory or file accessible across jobs and workflows, you can use cache.

The codes for storing & retrieving cache are the same. When the provided key doesn't hit anything, it will store the file/dir in the provided path into the cache with the provided key. Next time when you use the key and hit the cache, it will store the file/dir in the cache to the provided path.

e.g.

      - name: Cache vue/dist
        id: cache-vue-dist
        uses: actions/cache@v3
        with:
          path: vue/dist
          key: vue-dist-${{ github.sha }}

Note that when the cache can't be deleted by user (corresponding issue), so if your cache should be different across commits, you can append ${{ github.sha }} to your key.

change directory for a job

You can change a job's root directory. (It doesn't work for cache tho.)

    defaults:
      run:
        working-directory: ./vue

dependency

job1 -> job2

job2:
  needs: <job1>

Troubleshooting

Warning: getCacheEntry failed: Cache service responded with 503

Probably just a temporary error.

Workflow Not Running

Check if the branch name is correct in your trigger (e.g. main vs. master)