cuelang.org/go@v0.10.1/.github/workflows/trybot_dispatch.yml (about)

     1  # Code generated internal/ci/ci_tool.cue; DO NOT EDIT.
     2  
     3  name: Dispatch trybot
     4  "on":
     5    repository_dispatch: {}
     6    push:
     7      branches:
     8        - ci/test
     9  jobs:
    10    trybot:
    11      runs-on: ubuntu-22.04
    12      defaults:
    13        run:
    14          shell: bash
    15      if: ${{ ((github.ref == 'refs/heads/ci/test') && false) || github.event.client_payload.type == 'trybot' }}
    16      steps:
    17        - name: Write netrc file for cueckoo Gerrithub
    18          run: |-
    19            cat <<EOD > ~/.netrc
    20            machine review.gerrithub.io
    21            login cueckoo
    22            password ${{ secrets.CUECKOO_GERRITHUB_PASSWORD }}
    23            EOD
    24            chmod 600 ~/.netrc
    25        - id: payload
    26          if: github.repository == 'cue-lang/cue' && (github.ref == 'refs/heads/ci/test')
    27          name: Write fake payload
    28          run: |-
    29            cat <<EOD >> $GITHUB_OUTPUT
    30            value<<DOE
    31            null
    32            DOE
    33            EOD
    34        - if: github.event.client_payload.type != 'trybot'
    35          name: Trigger TryBot (fake data)
    36          run: |-
    37            mkdir tmpgit
    38            cd tmpgit
    39            git init -b initialbranch
    40            git config user.name cueckoo
    41            git config user.email cueckoo@gmail.com
    42            git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)"
    43            git remote add origin  https://review.gerrithub.io/a/cue-lang/cue
    44  
    45            git fetch origin ${{ fromJSON(steps.payload.outputs.value).ref }}
    46            git checkout -b local_${{ fromJSON(steps.payload.outputs.value).targetBranch }} FETCH_HEAD
    47  
    48            # Error if we already have dispatchTrailer according to git log logic.
    49            # See earlier check for GitHub expression logic check.
    50            x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')"
    51            if [[ "$x" != "" ]]
    52            then
    53            	 echo "Ref ${{ fromJSON(steps.payload.outputs.value).ref }} already has a Dispatch-Trailer"
    54            	 exit 1
    55            fi
    56  
    57            # Add the trailer because we don't have it yet. GitHub expressions do not have a
    58            # substitute or quote capability. So we do that in shell. We also strip out the
    59            # indenting added by toJSON. We ensure that the type field is first in order
    60            # that we can safely check for specific types of dispatch trailer.
    61            #
    62            # Use bash heredoc so that JSON's use of double quotes does
    63            # not get interpreted as shell.
    64            trailer="$(cat <<EOD | jq -r -c '{type} + .'
    65            ${{ toJSON(fromJSON(steps.payload.outputs.value)) }}
    66            EOD
    67            )"
    68            git log -1 --format=%B | git interpret-trailers --trailer "Dispatch-Trailer: $trailer" | git commit --amend -F -
    69            git log -1
    70  
    71            success=false
    72            for try in {1..20}; do
    73            	echo "Push to trybot try $try"
    74            	if git push -f https://github.com/cue-lang/cue-trybot local_${{ fromJSON(steps.payload.outputs.value).targetBranch }}:${{ fromJSON(steps.payload.outputs.value).targetBranch }}; then
    75            		success=true
    76            		break
    77            	fi
    78            	sleep 1
    79            done
    80            if ! $success; then
    81            	echo "Giving up"
    82            	exit 1
    83            fi
    84        - if: github.event.client_payload.type == 'trybot'
    85          name: Trigger TryBot (repository_dispatch payload)
    86          run: |-
    87            mkdir tmpgit
    88            cd tmpgit
    89            git init -b initialbranch
    90            git config user.name cueckoo
    91            git config user.email cueckoo@gmail.com
    92            git config http.https://github.com/.extraheader "AUTHORIZATION: basic $(echo -n cueckoo:${{ secrets.CUECKOO_GITHUB_PAT }} | base64)"
    93            git remote add origin  https://review.gerrithub.io/a/cue-lang/cue
    94  
    95            git fetch origin ${{ github.event.client_payload.ref }}
    96            git checkout -b local_${{ github.event.client_payload.targetBranch }} FETCH_HEAD
    97  
    98            # Error if we already have dispatchTrailer according to git log logic.
    99            # See earlier check for GitHub expression logic check.
   100            x="$(git log -1 --pretty='%(trailers:key=Dispatch-Trailer,valueonly)')"
   101            if [[ "$x" != "" ]]
   102            then
   103            	 echo "Ref ${{ github.event.client_payload.ref }} already has a Dispatch-Trailer"
   104            	 exit 1
   105            fi
   106  
   107            # Add the trailer because we don't have it yet. GitHub expressions do not have a
   108            # substitute or quote capability. So we do that in shell. We also strip out the
   109            # indenting added by toJSON. We ensure that the type field is first in order
   110            # that we can safely check for specific types of dispatch trailer.
   111            #
   112            # Use bash heredoc so that JSON's use of double quotes does
   113            # not get interpreted as shell.
   114            trailer="$(cat <<EOD | jq -r -c '{type} + .'
   115            ${{ toJSON(github.event.client_payload) }}
   116            EOD
   117            )"
   118            git log -1 --format=%B | git interpret-trailers --trailer "Dispatch-Trailer: $trailer" | git commit --amend -F -
   119            git log -1
   120  
   121            success=false
   122            for try in {1..20}; do
   123            	echo "Push to trybot try $try"
   124            	if git push -f https://github.com/cue-lang/cue-trybot local_${{ github.event.client_payload.targetBranch }}:${{ github.event.client_payload.targetBranch }}; then
   125            		success=true
   126            		break
   127            	fi
   128            	sleep 1
   129            done
   130            if ! $success; then
   131            	echo "Giving up"
   132            	exit 1
   133            fi