improve error handling, save branch name for push

This commit is contained in:
Luke Francl 2021-10-08 11:55:06 -07:00
parent e86c6b862f
commit 3fae59fb31

@ -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"