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

name: CI

# Controls when the action will run. 
on:
  # Triggers the workflow on push tag
  push:
    tags:
      - '*'

  # 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"
  build:
    # 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

      # Runs a set of commands using the runners shell
      - name: Run startup.sh
        run: |
           set -e
           echo start build
           export DOCKER_USERNAME="${{ secrets.DOCKER_USERNAME  }}"
           export DOCKER_PASSWORD="${{ secrets.DOCKER_PASSWORD }}"
           export GIT_SSH_SECRET="${{ secrets.GIT_SSH_SECRET }}"
           cd ./Publish/DevOps
           bash startup.sh
           echo build succeed!

      - name: Release-Create
        id: create_release
        uses: actions/create-release@v1
        if: hashFiles(env.release_assetPath)
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          release_name: ${{ env.release_name }}
          tag_name: ${{ env.release_tag }}
          draft: ${{ env.Release_draft }}
          prerelease: ${{ env.release_prerelease }}
          body: ${{ env.release_body }}
      - name: Release-Upload
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
        if: hashFiles(env.release_assetPath)
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a   `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
          asset_path: ${{ env.release_assetPath }}
          asset_name: ${{ env.release_assetName }}
          asset_content_type: ${{ env.release_contentType }}
