fix GitHub Actions error handling #394
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
pull_request: | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
# checkout the whole repo history | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.20' | |
- name: Setup Docker BuildX | |
uses: docker/setup-buildx-action@v2 | |
with: | |
version: https://github.com/docker/buildx.git#master | |
- name: Build | |
run: | | |
mkdir output | |
exit_status=0 | |
# only build images which are new or modified since the base | |
git diff --name-only --no-renames --diff-filter=AM "${{ github.event.pull_request.base.sha }}" \ | |
| grep Dockerfile$ \ | |
| xargs dirname \ | |
| xargs -n1 basename \ | |
| go run breadmaker.go --docker || exit_status=$? | |
[ $exit_status -gt 0 ] && echo ::error::Build failed! | |
shopt -s nullglob | |
for file in output/*.log; do | |
name=${file#output/} | |
name=${name%.log} | |
echo "::group::$name" | |
cat "$file" | |
echo "::endgroup::" | |
done | |
(exit $exit_status) |