|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + pages: write |
| 12 | + id-token: write |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: pages |
| 16 | + cancel-in-progress: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + validate: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Check out repository |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up Node.js |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: 22 |
| 30 | + |
| 31 | + - name: Validate Marp presentation |
| 32 | + run: | |
| 33 | + mkdir -p site |
| 34 | + npx --yes @marp-team/marp-cli@4 \ |
| 35 | + ai-agent-sandboxing.md \ |
| 36 | + --html \ |
| 37 | + --allow-local-files \ |
| 38 | + -o site/index.html |
| 39 | +
|
| 40 | + - name: Validate PowerShell syntax |
| 41 | + shell: pwsh |
| 42 | + run: | |
| 43 | + $hasErrors = $false |
| 44 | + $files = Get-ChildItem -Recurse -File -Include *.ps1, *.psm1, *.psd1 | |
| 45 | + Where-Object { $_.FullName -notmatch '[\\/]\.git[\\/]' } |
| 46 | +
|
| 47 | + foreach ($file in $files) { |
| 48 | + $tokens = $null |
| 49 | + $errors = $null |
| 50 | + [System.Management.Automation.Language.Parser]::ParseFile( |
| 51 | + $file.FullName, |
| 52 | + [ref] $tokens, |
| 53 | + [ref] $errors |
| 54 | + ) | Out-Null |
| 55 | +
|
| 56 | + if ($errors.Count -gt 0) { |
| 57 | + $hasErrors = $true |
| 58 | + $errors | ForEach-Object { |
| 59 | + Write-Error "$($file.FullName): $($_.Message)" |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +
|
| 64 | + if ($hasErrors) { |
| 65 | + exit 1 |
| 66 | + } |
| 67 | +
|
| 68 | + - name: Validate Bash syntax |
| 69 | + shell: bash |
| 70 | + run: | |
| 71 | + while IFS= read -r -d '' file; do |
| 72 | + bash -n "$file" |
| 73 | + done < <( |
| 74 | + find . -type f \( -name '*.sh' -o -name '*.bash' \) \ |
| 75 | + -not -path './.git/*' -print0 |
| 76 | + ) |
| 77 | +
|
| 78 | + - name: Validate Bicep files |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + if find . -type f -name '*.bicep' -not -path './.git/*' | grep -q .; then |
| 82 | + az bicep install |
| 83 | + while IFS= read -r file; do |
| 84 | + az bicep build --file "$file" --stdout > /dev/null |
| 85 | + done < <( |
| 86 | + find . -type f -name '*.bicep' -not -path './.git/*' |
| 87 | + ) |
| 88 | + fi |
| 89 | +
|
| 90 | + if find . -type f -name '*.bicepparam' -not -path './.git/*' | grep -q .; then |
| 91 | + az bicep install |
| 92 | + while IFS= read -r file; do |
| 93 | + az bicep build-params --file "$file" --stdout > /dev/null |
| 94 | + done < <( |
| 95 | + find . -type f -name '*.bicepparam' -not -path './.git/*' |
| 96 | + ) |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Configure GitHub Pages |
| 100 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 101 | + uses: actions/configure-pages@v5 |
| 102 | + |
| 103 | + - name: Upload GitHub Pages artifact |
| 104 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 105 | + uses: actions/upload-pages-artifact@v3 |
| 106 | + with: |
| 107 | + path: site |
| 108 | + |
| 109 | + deploy: |
| 110 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 111 | + needs: validate |
| 112 | + runs-on: ubuntu-latest |
| 113 | + environment: |
| 114 | + name: github-pages |
| 115 | + url: ${{ steps.deployment.outputs.page_url }} |
| 116 | + |
| 117 | + steps: |
| 118 | + - name: Deploy GitHub Pages |
| 119 | + id: deployment |
| 120 | + uses: actions/deploy-pages@v4 |
0 commit comments