name: Generate References
on: 
  push:
    branches:
      - 'master'
    paths:
      - packages/medusa/src/services/**
jobs:
  services:
    runs-on: ubuntu-latest
    steps:
      - name: Cancel Previous Runs
        uses: styfle/cancel-workflow-action@0.9.1
        with:
          access_token: ${{ github.token }}

      - name: Checkout
        uses: actions/checkout@v2.3.5
        with:
          fetch-depth: 0

      - name: Setup Node.js environment
        uses: actions/setup-node@v2.4.1
        with:
          node-version: "14"
          cache: "yarn"
        
      - name: Bootstrap packages
        uses: ./.github/actions/cache-bootstrap
        with:
          extension: unit-tests

      - name: Build Packages
        run: yarn build

      - name: Generate Services Reference
        run: yarn generate:services

      - uses: stefanzweifel/git-auto-commit-action@v4
        with: 
          commit_message: Automatically Generated Services Reference
          file_pattern: docs/content/*
          skip_dirty_check: false
