github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/.github/workflows/builds.yml (about) 1 name: Build Node Docker Images 2 # This workflow is used to build and push one-off images for specific node types. This is useful 3 # when deploying hotfixes or any time a change is not needed for all node roles. 4 5 on: 6 workflow_dispatch: 7 inputs: 8 tag: 9 type: string 10 description: 'Git tag/commit' 11 required: true 12 docker_tag: 13 type: string 14 description: 'Docker tag' 15 required: true 16 # GHA doesn't support multi-selects, so simulating it with one boolean for each option 17 build_access: 18 type: boolean 19 description: 'Access' 20 required: false 21 build_collection: 22 type: boolean 23 description: 'Collection' 24 required: false 25 build_consensus: 26 type: boolean 27 description: 'Consensus' 28 required: false 29 build_execution: 30 type: boolean 31 description: 'Execution' 32 required: false 33 build_verification: 34 type: boolean 35 description: 'Verification' 36 required: false 37 build_observer: 38 type: boolean 39 description: 'Observer' 40 required: false 41 # GHA allows only up to 10 inputs - regroup two entries in one 42 include_alternative_builds: 43 type: boolean 44 description: 'Build amd64 `without_adx` and `without_netgo_without_adx` images, and arm64 images' 45 required: false 46 47 jobs: 48 # matrix_builder generates a matrix that includes the roles selected in the input 49 matrix_builder: 50 name: Setup build jobs 51 runs-on: ubuntu-latest 52 outputs: 53 matrix: ${{ steps.generate.outputs.matrix }} 54 steps: 55 - name: Print all input variables 56 run: echo '${{ toJson(inputs) }}' | jq 57 58 - id: generate 59 run: | 60 roles=() 61 if [[ "${{ inputs.build_access }}" = "true" ]]; then 62 roles+=( "access" ) 63 fi 64 if [[ "${{ inputs.build_collection }}" = "true" ]]; then 65 roles+=( "collection" ) 66 fi 67 if [[ "${{ inputs.build_consensus }}" = "true" ]]; then 68 roles+=( "consensus" ) 69 fi 70 if [[ "${{ inputs.build_execution }}" = "true" ]]; then 71 roles+=( "execution" ) 72 fi 73 if [[ "${{ inputs.build_verification }}" = "true" ]]; then 74 roles+=( "verification" ) 75 fi 76 if [[ "${{ inputs.build_observer }}" = "true" ]]; then 77 roles+=( "observer" ) 78 fi 79 rolesJSON=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${roles[@]}") 80 echo "matrix={\"role\":$(echo $rolesJSON)}" >> $GITHUB_OUTPUT 81 82 docker-push: 83 name: ${{ matrix.role }} images 84 runs-on: ubuntu-latest 85 needs: matrix_builder 86 87 # setup jobs for each role 88 strategy: 89 fail-fast: false 90 matrix: ${{ fromJson(needs.matrix_builder.outputs.matrix) }} 91 92 steps: 93 - name: Setup Go 94 uses: actions/setup-go@v4 95 with: 96 go-version: '1.19' 97 98 - name: Checkout repo 99 uses: actions/checkout@v2 100 with: 101 ref: ${{ inputs.tag }} 102 103 # Provide Google Service Account credentials to Github Action, allowing interaction with the Google Container Registry 104 # Logging in as github-actions@dl-flow.iam.gserviceaccount.com 105 - id: auth 106 uses: google-github-actions/auth@v1 107 with: 108 credentials_json: ${{ secrets.GCR_SERVICE_KEY_SECRET }} 109 - name: Set up Google Cloud SDK 110 uses: google-github-actions/setup-gcloud@v1 111 - name: Authenticate docker with gcloud 112 run: | 113 gcloud auth configure-docker 114 115 - name: Build/Push ${{ matrix.role }} amd64 images with adx (default) 116 env: 117 IMAGE_TAG: ${{ inputs.docker_tag }} 118 CADENCE_DEPLOY_KEY: ${{ secrets.CADENCE_DEPLOY_KEY }} 119 run: | 120 make docker-build-${{ matrix.role }}-with-adx docker-push-${{ matrix.role }}-with-adx 121 122 - name: Build/Push ${{ matrix.role }} amd64 images without netgo and without adx, arm64 images 123 if: ${{ inputs.include_alternative_builds }} 124 env: 125 IMAGE_TAG: ${{ inputs.docker_tag }} 126 CADENCE_DEPLOY_KEY: ${{ secrets.CADENCE_DEPLOY_KEY }} 127 run: | 128 make docker-build-${{ matrix.role }}-without-adx docker-push-${{ matrix.role }}-without-adx \ 129 docker-build-${{ matrix.role }}-without-netgo-without-adx docker-push-${{ matrix.role }}-without-netgo-without-adx \ 130 docker-cross-build-${{ matrix.role }}-arm docker-push-${{ matrix.role }}-arm 131 132 133