gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/.github/workflows/go.yml (about)

     1  # This workflow generates the Go branch. Note that this does not test the Go
     2  # branch, as this is rolled into the main continuous integration pipeline. This
     3  # workflow simply generates and pushes the branch, as long as appropriate
     4  # permissions are available.
     5  name: "Go"
     6  "on":
     7    push:
     8      branches:
     9        - master
    10    pull_request:
    11      branches:
    12        - master
    13        - "feature/**"
    14  
    15  concurrency:
    16    group: ${{ github.workflow }}-${{ github.ref }}
    17    cancel-in-progress: true
    18  
    19  jobs:
    20    generate:
    21      runs-on: ubuntu-latest
    22      steps:
    23      - id: setup
    24        run: |
    25          if ! [[ -z "${{ secrets.GO_TOKEN }}" ]]; then
    26            echo has_token=true >> "$GITHUB_OUTPUT"
    27          else
    28            echo has_token=false >> "$GITHUB_OUTPUT"
    29          fi
    30      - run: |
    31          jq -nc '{"state": "pending", "context": "go tests"}' | \
    32          curl -sL -X POST -d @- \
    33              -H "Content-Type: application/json" \
    34              -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
    35              "${{ github.event.pull_request.statuses_url }}"
    36        if: github.event_name == 'pull_request'
    37      - uses: actions/checkout@v3.3.0
    38        if: github.event_name == 'push' && steps.setup.outputs.has_token == 'true'
    39        with:
    40          fetch-depth: 0
    41          token: '${{ secrets.GO_TOKEN }}'
    42      - uses: actions/checkout@v3.3.0
    43        if: github.event_name == 'pull_request' || steps.setup.outputs.has_token != 'true'
    44        with:
    45          fetch-depth: 0
    46      - uses: actions/setup-go@v5.0.1
    47        with:
    48          go-version-file: 'go.mod'
    49      - run: tools/go_branch.sh
    50      - run: git checkout go && git clean -xf . && go build ./...
    51      - if: github.event_name == 'push'
    52        run: |
    53          git remote add upstream "https://github.com/${{ github.repository }}"
    54          git push upstream go:go
    55      - if: ${{ success() && github.event_name == 'pull_request' }}
    56        run: |
    57          jq -nc '{"state": "success", "context": "go tests"}' | \
    58          curl -sL  -X POST -d @- \
    59              -H "Content-Type: application/json" \
    60              -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
    61              "${{ github.event.pull_request.statuses_url }}"
    62      - if: ${{ failure() && github.event_name == 'pull_request' }}
    63        run: |
    64          jq -nc '{"state": "failure", "context": "go tests"}' | \
    65          curl -sL  -X POST -d @- \
    66              -H "Content-Type: application/json" \
    67              -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
    68              "${{ github.event.pull_request.statuses_url }}"