name: Release

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  release:
    name: release
    if: ${{ github.ref == 'refs/heads/main' }}
    runs-on: ubuntu-latest
    permissions:
      actions: write
      contents: write
      pull-requests: write
    steps:
      - name: Release
        id: release
        uses: google-github-actions/release-please-action@v4
        with:
          token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

      - name: Trigger Docker Image Publish
        if: ${{ steps.release.outputs['release_created'] }}
        env:
          GH_TOKEN: ${{ github.token }}
          TAG_NAME: ${{ steps.release.outputs.tag_name }}
        run: |
          gh workflow run --repo ${GITHUB_REPOSITORY} deploy-docker.yml -f ref=${TAG_NAME}
