# This is a basic workflow to help you get started with Actions

name: AutoSendMessage

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ stable ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  auto-merge-log:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: checkout/changeLog
        uses: actions/checkout@v2
        with:
          repository: innerken-gmbh/aaden-vue-change-log
          path: changeLog
          token: ${{ secrets.PT }}

      # Runs a set of commands using the runners shell
      - name: send message to log
        run: |
          PROJECT_NAME=$(basename -s .git $(git config --get remote.origin.url))
          LOG=$(git log -1 --pretty=format:"%h::$PROJECT_NAME::%s")
          echo $LOG
          cd changeLog
          echo $LOG >>CHANGELOG.md
          node scripts/save-change-log.mjs $LOG
          git config user.name Haodong Ju
          git config user.email juhaodong@gmail.com
          git add .
          git commit -m "[GITHUB CI] Update changelog"
          git push
        shell: bash

