Skip to content

Commit

Permalink
gha env test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-williams committed Feb 10, 2024
1 parent da1a734 commit 22fd9f2
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions .github/workflows/call-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test actions/checkout ref expansion
name: Test env context
on:
workflow_dispatch:
inputs:
Expand All @@ -8,27 +8,13 @@ on:
description: "The branch, tag, or SHA to checkout"
jobs:
run:
name: Test actions/checkout ref expansion
name: Test env context
runs-on: ubuntu-latest
steps:
- name: Resolve inputs.ref to full SHA
id: resolve-ref
# https://github.com/actions/checkout/issues/265
- name: test env context
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
test1: ${{ inputs.ref }}
run: |
ref=${{ inputs.ref }}
sha=$(gh api /repos/$GITHUB_REPOSITORY/commits/$ref | jq -r .sha)
if [ -z "$sha" ]; then
echo "Failed to resolve ref $ref (possibly missing GH_TOKEN env var?)" >&2
exit 1
fi
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
export test2=yay2
echo "env.test1: ${{ env.test1 || 'boo1' }}"
echo "env.test2: ${{ env.test2 || 'boo2' }}"

0 comments on commit 22fd9f2

Please sign in to comment.