Skip to content

Test env context

Test env context #7

Workflow file for this run

name: Test actions/checkout ref expansion
on:
workflow_dispatch:
inputs:
ref:
type: string
default: main
description: "The branch, tag, or SHA to checkout"
jobs:
run:
name: Test actions/checkout ref expansion
runs-on: ubuntu-latest
steps:
- name: Resolve inputs.ref to full SHA
id: resolve-ref
# https://github.com/actions/checkout/issues/265
run: |
ref=${{ inputs.ref }}
sha=$(gh api /repos/$GITHUB_REPOSITORY/commits/$ref | jq -r .sha)
echo "Expanded ref $ref to SHA $sha"
echo "sha=$sha" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: ${{ steps.resolve-ref.outputs.sha }}
- name: Verify checked out commit
run: |
echo "Output SHA: ${{ steps.resolve-ref.outputs.sha }}"
git log -1