From 3fae59fb31b4ffa98e7cf9c3cc6017a500ee8f7f Mon Sep 17 00:00:00 2001 From: Luke Francl Date: Fri, 8 Oct 2021 11:55:06 -0700 Subject: [PATCH] improve error handling, save branch name for push --- .github/workflows/sync-linguist.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sync-linguist.yml b/.github/workflows/sync-linguist.yml index 365a0a7..816337f 100644 --- a/.github/workflows/sync-linguist.yml +++ b/.github/workflows/sync-linguist.yml @@ -8,7 +8,13 @@ jobs: - uses: actions/setup-go@v2 - uses: actions/checkout@v2 - name: Create a branch - run: git checkout -b feature/sync-linguist-$(date +%s) + id: branch + run: | + set -euo pipefail + IFS=$'\n\t' + branch_name=$(feature/sync-linguist-$(date +%s)) + git checkout -b $branch_name + echo "::set-output name=branch_name::$branch_name" - uses: actions/checkout@v2 with: repository: github/linguist @@ -19,7 +25,8 @@ jobs: # the `grep -v "-"` is to exclude any pre-release versions. # Linguist doesn't have any right now, but just in case. run: | - set -e + set -euo pipefail + IFS=$'\n\t' cd .linguist latest=$(git tag --list | \ grep -v "-" | \ @@ -33,13 +40,14 @@ jobs: - name: Commit changes id: commit run: | - set -e + set -euo pipefail + IFS=$'\n\t' if [[ -n "$(git status --porcelain)" ]]; then git config user.name github-actions git config user.email github-actions@github.com git add . git commit -m "Updated Linguist to ${{ steps.linguist-release.outputs.linguist_version }}" - git push + git push --set-upstream origin ${{ steps.branch.outputs.branch_name }} echo "::set-output name=needs_pr::true" else echo "::set-output name=needs_pr::false"