Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • In your repo, create a directory called .github/workflows/, and inside there, create an arbitrary named yml file for your workflow. For example, .github/workflows/example-workflow.yml, with code like:

    Code Block
    name: learnthis-is-githubthe-actions
    runaction-name:  ${{ github.actor }} is learning GitHub Actions # Pick a name you like.
    on: [push]
    jobs:
      checkthis-is-bats-version:
        runs-on: ubuntu-latestthe-job-name:      steps:   # Pick a name - uses: actions/checkout@v4you like.
          runs- useson: actions/setupself-node@v3hosted
            withsteps:
              node-version: '14'- uses: actions/checkout@v4
          - run: npmecho install -g bats
          - run: bats -v
    "hello world"
    
  • For details on formatting this file, see Understanding GitHub Actions: Understanding the workflow file. For your convenience, highlights are provided here:

  • Notice the jobs field contains a hash, or dictionary, of jobs. In this example, check-bats-version is an arbitrary job name. You may specify whatever job name is appropriate for your repo. You may create more than one job, which will perform multiple actions on multiple runners.

  • runs-on specifies which runner you wish your job to run on.

    • For a list of github hosted runners in the cloud, see About GitHub-hosted runners

    • For a list of Tufts on-prem locally hosted runners, browse to your repository on GitHub, then click Settings > Actions > Runners. It is NOT recommended to specify a runner by name. Instead, use a tag such as self-hosted or openshift so your job will run on any available self-hosted runner. If you specify a comma-separated list of tags, e.g. self-hosted, rhel-8 it will only run on runners that match all of the tags.

    • If you have special requirements and cannot run your job on a Tufts local runner on shared infrastructure (due to resource or security requirements) please contact it@tufts.edu and request ESCP to setup a private or custom runner, in a restricted Runner Group. Ask them to reference this page: Making a private Github Runner

  • uses: actions/checkout@v4 This will checkout your repository in the working directory where the job runs. It is generally recommended to keep this line as-is, unless you have a reason to change it.uses: actions/setup-node@v3 is an example for a job that requires node. It is generally recommended to remove this line, or replace with something similar that you require.

  • run: lines specify actual commands that will run on the runner. You may specify more than one.