From 0a823056dd59614d205a4ea33042a96aec907ab4 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Tue, 26 Sep 2023 15:29:01 +0200 Subject: [PATCH] fix format pipeline --- .github/workflows/format-code.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml index 07f4505d..841294c6 100644 --- a/.github/workflows/format-code.yml +++ b/.github/workflows/format-code.yml @@ -47,11 +47,17 @@ jobs: - name: Format run: make format - # actions/checkout fetches only a single commit in a detached HEAD state. Therefore - # we need to pass the current branch, otherwise we can't commit the changes. - # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - - name: Commit Formatted Code - run: ./scripts/commit-code.sh $GITHUB_HEAD_REF + # Source: https://stackoverflow.com/a/58035262 + - name: Extract branch name + shell: bash + run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT + id: extract_branch + + # actions/checkout fetches only a single commit in a detached HEAD state. Therefore + # we need to pass the current branch, otherwise we can't commit the changes. + # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. + - name: Commit Formatted Code and API + run: ./scripts/commit-code.sh ${{ steps.extract_branch.outputs.branch }} - name: Make stop run: make stop