on:
  pull_request:
    types: [closed] # Merged pull-requests count as closed pull-requests.

jobs:
  create-new-version:
    runs-on: ubuntu-latest
    name: Create new version/tag
    steps:
      - uses: actions/checkout@v2
        if: github.event.pull_request.merged # Only run on merged pull-requests
        with:
          ref: ${{ github.event.pull_request.merge_commit_sha }} # Checkout the merged commit
          fetch-depth: 0
      - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* # Get all tags from the origin
        if: github.event.pull_request.merged # Only run on merged pull-requests
      - uses: Financial-Times/origami-version@v1.2.1
        name: Create new version/tag
        if: github.event.pull_request.merged # Only run on merged pull-requests
        with:
          github-token: ${{ secrets.ORIGAMI_GITHUB_TOKEN }}
