Skip to content

Commit

Permalink
use checkout to get short sha
Browse files Browse the repository at this point in the history
  • Loading branch information
jblom committed Oct 2, 2024
1 parent 77a90a8 commit 851725b
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions .github/workflows/build-push-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ jobs:
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Add sha to GITHUB_OUTPUT
id: git-sha-short
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

- name: Setup Buildx
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1

Expand All @@ -22,17 +29,6 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Extract branch name
id: git-branch
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT

- name: Get git sha
id: git-sha-short
# this command requires git checkout. Want to avoid. Trying calling gh api
# run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
run: echo sha=$(cut -c 1-7 <<< `gh api "repos/${{ github.repository }}/commits/${{steps.git-branch.outputs.branch}}" --jq .sha`) >> $GITHUB_OUTPUT

- name: Configure remote
id: remote
run: |
Expand Down

0 comments on commit 851725b

Please sign in to comment.