|
| 1 | +# |
| 2 | +# Rough schema for generated data: |
| 3 | +# |
| 4 | +# config: {ci, tables, envoy} |
| 5 | +# run: {run: boolean} |
| 6 | +# request: {...request-vars, version, version-current, build-image, build-image-current} |
| 7 | +# checks: {check: {name, advice, id, action}} |
| 8 | +# |
| 9 | +# |
| 10 | +# CI is only enabled if its the Envoy repo or specifically enabled by vars.ENVOY_CI |
| 11 | + |
| 12 | +inputs: |
| 13 | + branch-name: |
| 14 | + type: string |
| 15 | + required: true |
| 16 | + config-file: |
| 17 | + type: string |
| 18 | + default: ./.github/config.yml |
| 19 | + started: |
| 20 | + type: number |
| 21 | + required: true |
| 22 | + token: |
| 23 | + type: string |
| 24 | + required: true |
| 25 | + trusted: |
| 26 | + type: boolean |
| 27 | + default: false |
| 28 | + template-script-ref-file: |
| 29 | + type: string |
| 30 | + default: | |
| 31 | + git fetch \($remote) \($ref) |
| 32 | + OUTPUT=\"$(git show \($remote)/\($ref):\($filename))\" |
| 33 | + template-script-diff: |
| 34 | + type: string |
| 35 | + default: | |
| 36 | + git fetch \($remote) \($ref) |
| 37 | + OUTPUT=\"$(git diff --name-only \($diff) \($remote)/\($ref))\" |
| 38 | + vars: |
| 39 | + type: string |
| 40 | + required: true |
| 41 | + version-file: |
| 42 | + type: string |
| 43 | + default: VERSION.txt |
| 44 | + |
| 45 | +outputs: |
| 46 | + data: |
| 47 | + value: ${{ steps.data.outputs.value }} |
| 48 | + |
| 49 | + |
| 50 | +runs: |
| 51 | + using: composite |
| 52 | + steps: |
| 53 | + |
| 54 | + # Check current/requested config (currently only build-images can be overridden) |
| 55 | + - uses: envoyproxy/toolshed/gh-actions/bson@2d46e676172c17700ec475a69ae0893eb55b484d |
| 56 | + id: config |
| 57 | + with: |
| 58 | + title: fetch ${{ inputs.branch-name }}:${{ inputs.config-file }} |
| 59 | + input: | |
| 60 | + filename: ${{ inputs.config-file }} |
| 61 | + branch: ${{ inputs.branch-name }} |
| 62 | + remote: origin |
| 63 | + filter: | |
| 64 | + .filename as $filename |
| 65 | + | .remote as $remote |
| 66 | + | .branch as $ref |
| 67 | + | ("${{ inputs.template-script-ref-file }}" | bash::output) |
| 68 | + result-format: yaml |
| 69 | + result-filter-options: |
| 70 | + result-filter: . |
| 71 | + |
| 72 | + - id: build-images |
| 73 | + uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d |
| 74 | + with: |
| 75 | + input-format: yaml-path |
| 76 | + input: ${{ inputs.config-file }} |
| 77 | + print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }} |
| 78 | + filter: | |
| 79 | + .["build-image"].repo as $repo |
| 80 | + | (.["build-image"].tag | validate::sha(40)) as $tag |
| 81 | + | (.["build-image"].sha | validate::sha(64)) as $sha |
| 82 | + | (.["build-image"]["mobile-sha"] | validate::sha(64)) as $mobileSha |
| 83 | + | {"default": "\($repo):\($tag)@sha256:\($sha)", |
| 84 | + "mobile": "\($repo):mobile-\($tag)@sha256:\($mobileSha)"} |
| 85 | + | . as $requested |
| 86 | + | {$requested} |
| 87 | +
|
| 88 | + # Check request version |
| 89 | + - uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d |
| 90 | + name: Validate given version string |
| 91 | + id: version |
| 92 | + with: |
| 93 | + input-format: string-path |
| 94 | + options: -Rr |
| 95 | + input: ${{ inputs.version-file }} |
| 96 | + filter: | |
| 97 | + . |
| 98 | + | validate::version |
| 99 | + | endswith("-dev") as $isdev |
| 100 | + | split(".") |
| 101 | + | {major: (.[0] | fromjson), |
| 102 | + minor: (.[1] | fromjson), |
| 103 | + patch: (.[2] | rtrimstr("-dev") | fromjson), |
| 104 | + "dev": $isdev} |
| 105 | + | {requested: .} |
| 106 | +
|
| 107 | + - id: request |
| 108 | + uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d |
| 109 | + with: |
| 110 | + input: | |
| 111 | + actor: ${{ toJSON(github.actor) }} |
| 112 | + event: ${{ toJSON(github.event) }} |
| 113 | + event_name: ${{ github.event_name }} |
| 114 | + sha: ${{ github.sha }} |
| 115 | + build_images: ${{ steps.build-images.outputs.value }} |
| 116 | + input-format: yaml |
| 117 | + filter: | |
| 118 | + . |
| 119 | + | .actor as $actor |
| 120 | + | .event as $event |
| 121 | + | .event_name as $event_name |
| 122 | + | .sha as $sha |
| 123 | + | .build_images as $build_images |
| 124 | + | $build_images.requested as $build_image |
| 125 | + | {} |
| 126 | + | .ref = "${{ inputs.branch-name }}" |
| 127 | + | .sha = $sha |
| 128 | + | . * {"actor": { |
| 129 | + name: $actor, |
| 130 | + icon: $event.sender.avatar_url}, |
| 131 | + "started": ${{ inputs.started }}, |
| 132 | + "target-branch": "${{ inputs.branch-name }}", |
| 133 | + "trusted": ${{ inputs.trusted }}, |
| 134 | + "version": ${{ toJSON(fromJSON(steps.version.outputs.value).requested) }}, |
| 135 | + "version-current": ${{ toJSON(fromJSON(steps.version.outputs.value).current) }}, |
| 136 | + "build-image": $build_image, |
| 137 | + "build-image-current": $build_images.current} |
| 138 | +
|
| 139 | + - name: Run config |
| 140 | + id: run-config |
| 141 | + uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d |
| 142 | + with: |
| 143 | + input-format: yaml |
| 144 | + input: ${{ toJSON(fromJSON(steps.config.outputs.output).run) }} |
| 145 | + |
| 146 | + - uses: envoyproxy/toolshed/gh-actions/jq@2d46e676172c17700ec475a69ae0893eb55b484d |
| 147 | + name: Create data |
| 148 | + id: data |
| 149 | + with: |
| 150 | + input: ${{ inputs.vars }} |
| 151 | + filter: | |
| 152 | + . |
| 153 | + | ${{ github.repository == 'envoyproxy/envoy' }} as $isEnvoyRepo |
| 154 | + | . as $vars |
| 155 | + | ${{ steps.config.outputs.output }} as $config |
| 156 | + | ${{ steps.request.outputs.value }} as $request |
| 157 | + | ($config |
| 158 | + | del(.checks, .config, .run, .["build-image"], .["agent-ubuntu"]) |
| 159 | + | .envoy = $config.config.envoy |
| 160 | + | .ci = { |
| 161 | + "agent-ubuntu": $config["agent-ubuntu"], |
| 162 | + "build-image": $config["build-image"]}) as $config |
| 163 | + | {$config, $request} |
| 164 | + print-result: ${{ fromJSON(env.CI_DEBUG || 'false') && true || false }} |
0 commit comments