## Updates demo site (https://github.com/zetxek/adritian-demo)
## triggers the update-hugo-module workflow in adritian-demo
## and the update-git-submodule workflow in the git-submodule-demo site
name: Update demo repos
permissions:
  contents: read
  id-token: write
  pages: write
  pull-requests: write
  checks: write
  statuses: write
  actions: write
  
on:
  push:
    ## run on push to main or a new semantic tag (ie: v1.2.3)
    branches: 
      - main
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'
  workflow_dispatch:

jobs:
  update:
    runs-on: ubuntu-latest

    steps:
          
      - name: Trigger Update Hugo Module workflow
        run: |
          curl -X POST \
            -H "Authorization: token ${{ secrets.PRIVATE_TOKEN_GITHUB }}" \
            -H "Accept: application/vnd.github.v3+json" \
            https://api.github.com/repos/zetxek/adritian-demo/actions/workflows/update-hugo-module.yml/dispatches \
            -d '{"ref":"main"}'
        
      - name: Trigger Update Git Submodule workflow
        run: |
          curl -X POST \
            -H "Authorization: token ${{ secrets.PRIVATE_TOKEN_GITHUB }}" \
            -H "Accept: application/vnd.github.v3+json" \
            https://github.com/zetxek/adritian-git-submodule-demo/actions/workflows/reset-submodule.yml/dispatches \
            -d '{"ref":"main"}'
