# Starts a sync test for every new release (pre-releases included)
name: Start Sync Test

on:
  release:
    types: [published]

permissions:
  id-token: write
  contents: read

jobs:
  start_release:
    name: Starts Sync Test
    runs-on: ubuntu-latest
    steps:
      - name: Set Env
        uses: Chia-Network/actions/setjobenv@main
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Trigger sync test workflow via github-glue
        uses: Chia-Network/actions/github/glue@main
        with:
          json_data: '{"test_ref": "${{ env.RELEASE_TAG }}"}'
          glue_url: "${{ secrets.GLUE_API_URL }}"
          glue_project: "sync-test/${{ env.RELEASE_TAG }}"
          glue_path: "start"

      - name: Trigger sync test workflow success via github-glue
        uses: Chia-Network/actions/github/glue@main
        with:
          json_data: '{"test_ref": "${{ env.RELEASE_TAG }}"}'
          glue_url: "${{ secrets.GLUE_API_URL }}"
          glue_project: "sync-test/${{ env.RELEASE_TAG }}"
          glue_path: "success/deploy"
