summaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/go.yml
blob: 802fe5ce532815ffda12d31a3e5e2d6fe4256522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This workflow generates the Go branch. Note that this does not test the Go
# branch, as this is rolled into the main continuous integration pipeline. This
# workflow simply generates and pushes the branch, as long as appropriate
# permissions are available.
name: "Go"
"on":
  push:
    branches:
      - master

jobs:
  generate:
    runs-on: ubuntu-latest
    steps:
    - id: setup
      run: |
        if ! [[ -z "${{ secrets.GO_TOKEN }}" ]]; then
          echo ::set-output name=has_token::true
        else
          echo ::set-output name=has_token::false
        fi
    - uses: actions/checkout@v2
      if: steps.setup.outputs.has_token == 'true'
      with:
        fetch-depth: 0
        token: '${{ secrets.GO_TOKEN }}'
    - uses: actions/checkout@v2
      if: steps.setup.outputs.has_token != 'true'
      with:
        fetch-depth: 0
    - uses: actions/setup-go@v2
      with:
        go-version: 1.14
    - uses: actions/cache@v1
      with:
        path: ~/go/pkg/mod
        key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
        restore-keys: |
          ${{ runner.os }}-go-
    - uses: actions/cache@v1
      with:
        path: ~/.cache/bazel
        key: ${{ runner.os }}-bazel-${{ hashFiles('WORKSPACE') }}
        restore-keys: |
          ${{ runner.os }}-bazel-
    - run: tools/go_branch.sh
    - run: |
        git remote add upstream "https://github.com/${{ github.repository }}"
        git push upstream go:go