name: Artifact gate practice
on:
  workflow_dispatch:
permissions:
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Make the training artifact
        run: |
          mkdir site
          printf '%s\n' 'Campux catalogue' > site/index.txt
          sha256sum site/index.txt > site/index.sha256
      - uses: actions/upload-artifact@v7
        with:
          name: catalogue
          path: site/
          if-no-files-found: error
  check:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: catalogue
          path: site/
      - name: Check the bytes and content
        run: |
          sha256sum -c site/index.sha256
          grep -Fx 'Campux catalogue' site/index.txt
  release-rehearsal:
    needs: check
    runs-on: ubuntu-latest
    environment: training-release
    steps:
      - uses: actions/download-artifact@v8
        with:
          name: catalogue
          path: site/
      - name: Verify the same bytes without deploying
        run: |
          sha256sum -c site/index.sha256
          printf '%s\n' 'Training gate passed; no Azure deployment performed'
