name: Release Published

# Event payload: https://developer.github.com/webhooks/event-payloads/#release
on:
  release:
    types: [published]

permissions:
  contents: read

jobs:
  release:
    name: Release Published
    strategy:
      matrix:
        os: 
          - ubuntu-latest
    runs-on: ${{ matrix.os }}
    permissions:
      contents: read
      pull-requests: read
      actions: write
    steps:

    # See https://github.com/peter-evans/repository-dispatch
    - name: Harden the runner (Audit all outbound calls)
      uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
      with:
        egress-policy: audit

    - name: Trigger event on caddyserver/dist
      uses: peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v4.0.0
      with:
        token: ${{ secrets.REPO_DISPATCH_TOKEN }}
        repository: caddyserver/dist
        event-type: release-tagged
        client-payload: '{"tag": "${{ github.event.release.tag_name }}"}'

    - name: Trigger event on caddyserver/caddy-docker
      uses: peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v4.0.0
      with:
        token: ${{ secrets.REPO_DISPATCH_TOKEN }}
        repository: caddyserver/caddy-docker
        event-type: release-tagged
        client-payload: '{"tag": "${{ github.event.release.tag_name }}"}'

