Skip to content
Snippets Groups Projects
github-actions.yml 3.67 KiB
Newer Older
Psnail's avatar
Psnail committed
name: CI

on:
  push:
Psnail's avatar
Psnail committed
    branches: [master, develop]
Psnail's avatar
Psnail committed
  pull_request:
    branches: "*"

jobs:

  build:
Psnail's avatar
Psnail committed
    name: ${{ matrix.os }} - Go ${{ matrix.go_version }}
    runs-on: ${{ matrix.os }}
Psnail's avatar
Psnail committed
    strategy:
      # If you want to matrix build , you can append the following list.
Psnail's avatar
Psnail committed
      matrix:
        go_version:
          - 1.13
        os:
          - ubuntu-latest
Psnail's avatar
Psnail committed

AlexStocks's avatar
AlexStocks committed
    env:
      DING_TOKEN: ${{ secrets.DING_TOKEN }}
      DING_SIGN: ${{ secrets.DING_SIGN }}

Psnail's avatar
Psnail committed
    steps:
Psnail's avatar
Psnail committed

    - name: Set up Go 1.x
      uses: actions/setup-go@v2
      with:
        go-version: ${{ matrix.go_version }}
Psnail's avatar
Psnail committed
      id: go

    - name: Check out code into the Go module directory
      uses: actions/checkout@v2

    - name: Cache dependencies
      uses: actions/cache@v2
      with:
        # Cache
        path: ~/go/pkg/mod
        # Cache key
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
        restore-keys: |
          ${{ runner.os }}-go-

Psnail's avatar
ci  
Psnail committed
    - name: Get dependencies
      run: |
        if [ -f Gopkg.toml ]; then
            curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
            dep ensure
        else
            go get -v -t -d ./...
Psnail's avatar
ci  
Psnail committed
        fi
    - name: Verify
Psnail's avatar
ci  
Psnail committed
      run: |
        make verify
邹毅贤's avatar
邹毅贤 committed
    - name: Integrate Test
邹毅贤's avatar
邹毅贤 committed
      run: |
        chmod +x integrate_test.sh && ./integrate_test.sh
邹毅贤's avatar
邹毅贤 committed

    - name: Post Coverage
AlexStocks's avatar
AlexStocks committed
      run: bash <(curl -s https://codecov.io/bash)

    - name: Hello world
      run: echo Hello world ${{ secrets.DING_TOKEN }} ${{ secrets.DING_SIGN }}

      # Because the contexts of push and PR are different, there are two Notify.
      # Notifications are triggered only in the dubbogo/gost repository.
    - name: DingTalk Message Notify only Push
      uses: zcong1993/actions-ding@v3.0.1
      # Whether job is successful or not, always () is always true.
      if: |
        always() &&
        github.event_name == 'push' &&
        github.repository == 'apache/dubbo-go'
      with:
        # DingDing bot token
        dingToken: ${{ env.DING_TOKEN }}
        secret: ${{ env.DING_SIGN }}
        # Post Body to send
        body: |
          {
            "msgtype": "markdown",
            "markdown": {
                "title": "Github Actions",
                "text": "## Github Actions \n - name: CI \n - repository: ${{ github.repository }} \n - trigger: ${{ github.actor }} \n - event: ${{ github.event_name }} \n - ref: ${{ github.ref }} \n - status: [${{ job.status	}}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) \n - environment: ${{ runner.os }} \n > SHA: [${{ github.sha }}](${{ github.event.compare }})"
            }
          }

    - name: DingTalk Message Notify only PR
      uses: zcong1993/actions-ding@v3.0.1
      if: |
        always() &&
        github.event_name == 'pull_request' &&
        github.repository == 'dubbogo/gost'
      with:
        dingToken: ${{ env.DING_TOKEN }}
        secret: ${{ env.DING_SIGN }}
        body: |
          {
            "msgtype": "markdown",
            "markdown": {
                "title": "Github Actions",
                "text": "## Github Actions \n - name: CI \n - repository: ${{ github.repository }} \n - pr_title: **${{ github.event.pull_request.title }}** \n - trigger: ${{ github.actor }} \n - event: ${{ github.event_name }} \n - ref: [${{ github.ref }}](${{ github.event.pull_request._links.html.href }}) \n - status: [${{ job.status	}}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) \n - environment: ${{ runner.os }} \n > SHA: [${{ github.sha }}](${{ github.event.pull_request._links.html.href }})"
            }
          }