ci: add PR checks #14
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: AI Gallery Template Gate Validation | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
id-token: write | |
pull-requests: write | |
security-events: write | |
jobs: | |
validation: | |
runs-on: ubuntu-latest | |
env: | |
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }} | |
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }} | |
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }} | |
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }} | |
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: "9.0.x" | |
- name: Install azd | |
uses: Azure/setup-azd@9653ee26f515b0ce205579894d4a49400f8da970 # v2 | |
- name: Install GH CLI # Because otherwise this cannot be executed locally with `gh act` | |
uses: dev-hanz-ops/install-gh-cli-action@8fff9050dae2d81b38f94500d8b74ad1d1d47410 # v0.2.0 | |
- id: validation | |
uses: microsoft/template-validation-action@e1206403a3695eb48b4426e3ec8b1919101ac770 # v0.3.5 | |
- name: Read file content | |
if: always() | |
id: read_validation_result | |
run: | | |
cat ${{ steps.validation.outputs.resultFile }} | |
FILE_CONTENT=$(cat ${{ steps.validation.outputs.resultFile }}) | |
echo "validation_result<<EOF" >> $GITHUB_ENV | |
echo "$FILE_CONTENT" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Post comment on PR | |
if: always() | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COMMENT_BODY: ${{ env.validation_result }} | |
run: | | |
gh pr comment ${{ github.event.pull_request.number }} --body "${{ env.COMMENT_BODY }}" |