Fix build workflow #3
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: | |
branches: | |
- main | |
paths: | |
- main.bicep | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
env: | |
BICEP_TEMPLATE_FILE: main.bicep | |
ARM_TEMPLATE_FILE: azuredeploy.json | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Build Bicep file | |
id: build | |
shell: bash {0} # Required to check exit code | |
run: | | |
az bicep build --file "$BICEP_TEMPLATE_FILE" --outfile "$ARM_TEMPLATE_FILE" | |
exit_code="$?" | |
if [[ "$exit_code" != 0 ]]; then | |
exit "$exit_code" | |
fi | |
git diff --exit-code "$ARM_TEMPLATE_FILE" | |
exit_code="$?" | |
echo "exit-code=$exit_code" >> "$GITHUB_OUTPUT" | |
- name: Push commit | |
if: steps.build.outputs.exit-code != 0 | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git add "$ARM_TEMPLATE_FILE" | |
git commit -m "Build Bicep file" | |
git push |