  
# Name is optional and if present must be used
# in the url path for badges
name: Trigger Site and CDN Build

# only run when a release has been "published"
on:
  release:
    types: [published]

jobs:
  dispatch:
    name: Dispatch Event
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [16.5]

    steps:
    # push dev (stage) version of site
    - name: Dispatch Site Build
      uses: peter-evans/repository-dispatch@v2
      with:
        # personal access tokens are under admin@zingsoft.com github account
        token: ${{ secrets.ZINGSOFT_REPOS_PERSONAL_ACCESS_TOKEN }}
        repository: zingsoftinc/zingchart-com
        event-type: new-zc-version
        client-payload: '{"ref": "${{ github.ref }}", "version": "${GITHUB_REF/refs\/tags\//}"}'
    # push master (live) branch of site
    # - name: Dispatch CDN Build
    #   uses: peter-evans/repository-dispatch@v1
    #   with:
    #     # personal access tokens are under admin@zingsoft.com  github account
    #     token: ${{ secrets.ZINGSOFT_REPOS_PERSONAL_ACCESS_TOKEN }}
    #     repository: zingsoftinc/zingchart-cdn
    #     event-type: new-zg-version
    #     client-payload: '{"ref": "${{ github.ref }}", "version": "${GITHUB_REF/refs\/tags\//}"}'

     # tweet:
     #   runs-on: ubuntu-latest
     #   steps:
     #     - name: Twitter Notification
     #       uses: ethomson/send-tweet-action@v1
     #       with:
     #         status: "New Release! Check out the new features at github.com\/zingchart\/ZingChart\/releases"
     #         consumer-key: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
     #         consumer-secret: ${{ secrets.TWITTER_CONSUMER_API_SECRET }}
     #         access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
     #         access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

  # slackNotification:
  #   name: Slack Notification
  #   runs-on: ubuntu-latest
  #   steps:
  #   - uses: actions/checkout@v3
  #   - name: Slack Notification
  #     uses: rtCamp/action-slack-notify@v2
  #     env:
  #       SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
