name: Publish Gem

on:
  release:
    types: [released]

permissions:
  contents: read

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
      - name: Setup Ruby
        uses: ruby/setup-ruby@3ff19f5e2baf30647122352b96108b1fbe250c64 # v1.299.0
        with:
          ruby-version: '3.3'
      - name: Build gem
        run: |
          gem build github-pages-health-check.gemspec
      - name: Publish gem
        env:
          GEM_HOST_API_KEY: ${{ secrets.PAGES_GEM_PUBLISHING }}
        run: |
          gem push github-pages-health-check-*.gem
