# This is a manually triggered workflow (hence on: workflow_dispatch).
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#manual-events

on: workflow_dispatch

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v2

      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-region: eu-west-2
          role-to-assume: arn:aws:iam::${{ secrets.ABLY_AWS_ACCOUNT_ID_SDK}}:role/ably-sdk-schemas-ably-common
          role-session-name: "${{ github.run_id }}-${{ github.run_number }}"

      - name: Read Tool Versions
        id: tool-versions
        run: echo "::set-output name=nodejs::$(sed -nr 's/nodejs ([0-9]+)/\1/p' .tool-versions)"

      - uses: actions/setup-node@v2
        with:
          node-version: ${{ steps.tool-versions.outputs.nodejs }}

      - name: Install Packages
        run: npm ci

      - name: Publish
        run: npm run publish:json-schemas
