What does `actions/checkout` do by default, and what are the common options?
BeginnerConceptWorkflow Anatomy & Execution Model
Answer
It clones the repo at GITHUB_SHA into $GITHUB_WORKSPACE, shallowly (fetch-depth: 1), and persists the GITHUB_TOKEN into the local git config so later git push works. Common options:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # full history (tags, git describe, changelogs)
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false # do not leave the token in .git/config
submodules: recursive
sparse-checkout: services/api
lfs: true
Set persist-credentials: false unless a later step really needs to push.
More on Workflow Anatomy & Execution Model
Define workflow, run, job, step, action and runner in one line each.BeginnerWhat is the minimum valid workflow file?BeginnerWhere must workflow files live, and does the file extension matter?BeginnerWhich version of the workflow file does GitHub use for a given run?IntermediateWhat does a GitHub-hosted runner give you at the start of a job?BeginnerShould you use `ubuntu-latest` or `ubuntu-24.04`?Beginner