|
| 1 | +# Environment variables defined in a calling workflow are not accessible to this reusable workflow. Refer to the documentation for further details on this limitation. |
| 2 | +name: build_azure_pipelinesrelease_template |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + goVersion: |
| 7 | + required: false |
| 8 | + default: 1.20.7 |
| 9 | + type: string |
| 10 | + registry: |
| 11 | + required: false |
| 12 | + default: ghcr.io/getporter/test |
| 13 | + type: string |
| 14 | + shouldPublish: |
| 15 | + required: false |
| 16 | + default: false |
| 17 | + type: boolean |
| 18 | + skipTests: |
| 19 | + required: false |
| 20 | + default: false |
| 21 | + type: boolean |
| 22 | +jobs: |
| 23 | + Validate-build: |
| 24 | + name: Native Compile |
| 25 | + runs-on: "{{ vars.}}" |
| 26 | + steps: |
| 27 | + - name: checkout |
| 28 | + uses: actions/checkout@v4.1.0 |
| 29 | + - uses: actions/setup-go@v4 |
| 30 | + with: |
| 31 | + go-version: "${{ inputs.GOVERSION }}" |
| 32 | + - name: Configure Agent |
| 33 | + run: go run mage.go ConfigureAgent |
| 34 | + - name: Native Build |
| 35 | + run: mage build |
| 36 | + shell: bash |
| 37 | + - name: Publish Native Binaries |
| 38 | + uses: actions/upload-artifact@v4.0.0 |
| 39 | + with: |
| 40 | + name: build-bin |
| 41 | + path: "${{ github.workspace }}/bin" |
| 42 | + Validate-xbuild: |
| 43 | + name: Cross Compile |
| 44 | + runs-on: ubuntu-latest |
| 45 | + steps: |
| 46 | + - name: checkout |
| 47 | + uses: actions/checkout@v4.1.0 |
| 48 | + - uses: actions/setup-go@v4 |
| 49 | + with: |
| 50 | + go-version: "${{ inputs.GOVERSION }}" |
| 51 | + - name: Configure Agent |
| 52 | + run: go run mage.go ConfigureAgent |
| 53 | + - name: Cross Compile |
| 54 | + run: mage XBuildAll |
| 55 | + shell: bash |
| 56 | + - name: Publish Release Binaries |
| 57 | + uses: actions/upload-artifact@v4.0.0 |
| 58 | + with: |
| 59 | + name: xbuild-bin |
| 60 | + path: "${{ github.workspace }}/bin" |
| 61 | + Validate-VetLint: |
| 62 | + name: Vet and Lint |
| 63 | + runs-on: ubuntu-latest |
| 64 | + steps: |
| 65 | + - name: checkout |
| 66 | + uses: actions/checkout@v4.1.0 |
| 67 | + - uses: actions/setup-go@v4 |
| 68 | + with: |
| 69 | + go-version: "${{ inputs.GOVERSION }}" |
| 70 | + - name: Configure Agent |
| 71 | + run: go run mage.go ConfigureAgent |
| 72 | + - name: Vet |
| 73 | + run: mage Vet |
| 74 | + shell: bash |
| 75 | + - name: Lint |
| 76 | + run: mage Lint |
| 77 | + shell: bash |
| 78 | + Validate-unit_test: |
| 79 | + name: Unit Test |
| 80 | + runs-on: ubuntu-latest |
| 81 | + if: !(inputs.skipTests) |
| 82 | + steps: |
| 83 | + - name: checkout |
| 84 | + uses: actions/checkout@v4.1.0 |
| 85 | + - uses: actions/setup-go@v4 |
| 86 | + with: |
| 87 | + go-version: "${{ inputs.GOVERSION }}" |
| 88 | + - name: Configure Agent |
| 89 | + run: go run mage.go ConfigureAgent |
| 90 | + - name: Unit Test |
| 91 | + run: mage TestUnit |
| 92 | + shell: bash |
| 93 | + Validate-integration_test: |
| 94 | + env: |
| 95 | + GHCR_IOGETPORTER_DOCKER_REGISTRY: https://ghcr.io |
| 96 | + GHCR_IOGETPORTER_DOCKER_USERNAME: getporterbot |
| 97 | + name: Integration Test |
| 98 | + needs: |
| 99 | + - Validate-build |
| 100 | + runs-on: ubuntu-latest |
| 101 | + steps: |
| 102 | + - name: checkout |
| 103 | + uses: actions/checkout@v4.1.0 |
| 104 | + - uses: actions/setup-go@v4 |
| 105 | + with: |
| 106 | + go-version: "${{ inputs.GOVERSION }}" |
| 107 | + - name: Download Bin |
| 108 | + uses: actions/download-artifact@v4.1.0 |
| 109 | + with: |
| 110 | + name: build-bin |
| 111 | + path: bin |
| 112 | + - name: Docker Login |
| 113 | + uses: docker/login-action@v3.0.0 |
| 114 | + with: |
| 115 | + registry: "${{ env.GHCR_IOGETPORTER_DOCKER_REGISTRY }}" |
| 116 | + username: "${{ env.GHCR_IOGETPORTER_DOCKER_USERNAME }}" |
| 117 | + password: "${{ secrets.GHCR_IOGETPORTER_DOCKER_PASSWORD }}" |
| 118 | + - name: Configure Agent |
| 119 | + run: go run mage.go ConfigureAgent SetBinExecutable |
| 120 | + - name: Integration Test |
| 121 | + run: mage -v TestIntegration |
| 122 | + Validate-smoke_test: |
| 123 | + name: Run smoke tests on |
| 124 | + needs: |
| 125 | + - Validate-xbuild |
| 126 | + runs-on: |
| 127 | + - self-hosted |
| 128 | + if: success() && !(inputs.skipTests) |
| 129 | + steps: |
| 130 | + - name: checkout |
| 131 | + uses: actions/checkout@v4.1.0 |
| 132 | + - uses: actions/setup-go@v4 |
| 133 | + with: |
| 134 | + go-version: "${{ inputs.GOVERSION }}" |
| 135 | + - name: Download Cross-Compiled Porter Binaries |
| 136 | + uses: actions/download-artifact@v4.1.0 |
| 137 | + with: |
| 138 | + name: xbuild-bin |
| 139 | + path: bin |
| 140 | + - name: Setup Bin |
| 141 | + run: go run mage.go ConfigureAgent UseXBuildBinaries |
| 142 | + - name: Run Smoke Tests |
| 143 | + run: mage -v TestSmoke |
| 144 | + Publish-publish_binaries: |
| 145 | + name: Publish Binaries |
| 146 | + needs: |
| 147 | + - Validate-build |
| 148 | + - Validate-xbuild |
| 149 | + - Validate-VetLint |
| 150 | + - Validate-unit_test |
| 151 | + - Validate-integration_test |
| 152 | + - Validate-smoke_test |
| 153 | + runs-on: ubuntu-latest |
| 154 | + if: success() && inputs.shouldPublish |
| 155 | + steps: |
| 156 | + - name: checkout |
| 157 | + uses: actions/checkout@v4.1.0 |
| 158 | + - uses: actions/setup-go@v4 |
| 159 | + with: |
| 160 | + go-version: "${{ inputs.GOVERSION }}" |
| 161 | + - name: Download Cross-Compiled Porter Binaries |
| 162 | + uses: actions/download-artifact@v4.1.0 |
| 163 | + with: |
| 164 | + name: xbuild-bin |
| 165 | + path: bin |
| 166 | + - name: Setup Bin |
| 167 | + run: go run mage.go ConfigureAgent UseXBuildBinaries |
| 168 | + - name: Publish Porter Binaries |
| 169 | + env: |
| 170 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 171 | + run: mage PublishPorter PublishMixins |
| 172 | + Publish-publish_docker: |
| 173 | + env: |
| 174 | + DOCKER_REGISTRY: |
| 175 | + DOCKER_USERNAME: |
| 176 | + name: Publish Docker Images |
| 177 | + needs: |
| 178 | + - Validate-build |
| 179 | + - Validate-xbuild |
| 180 | + - Validate-VetLint |
| 181 | + - Validate-unit_test |
| 182 | + - Validate-integration_test |
| 183 | + - Validate-smoke_test |
| 184 | + runs-on: ubuntu-latest |
| 185 | + if: success() && inputs.shouldPublish |
| 186 | + steps: |
| 187 | + - name: checkout |
| 188 | + uses: actions/checkout@v4.1.0 |
| 189 | + - uses: actions/setup-go@v4 |
| 190 | + with: |
| 191 | + go-version: "${{ inputs.GOVERSION }}" |
| 192 | + - name: Download Cross-Compiled Porter Binaries |
| 193 | + uses: actions/download-artifact@v4.1.0 |
| 194 | + with: |
| 195 | + name: xbuild-bin |
| 196 | + path: bin |
| 197 | + - name: Setup Bin |
| 198 | + run: go run mage.go ConfigureAgent UseXBuildBinaries |
| 199 | + # Unable to determine registry '${{parameters.registry}}' type. The service connection was not found or the authentication type not supported. |
| 200 | + - name: Docker Login |
| 201 | + uses: docker/login-action@v3.0.0 |
| 202 | + with: |
| 203 | + registry: "${{ env.DOCKER_REGISTRY }}" |
| 204 | + username: "${{ env.DOCKER_USERNAME }}" |
| 205 | + password: "${{ secrets.DOCKER_PASSWORD }}" |
| 206 | + - name: Publish Docker Images to ${{inputs.registry}} |
| 207 | + run: PORTER_REGISTRY=${{inputs.registry}} mage PublishImages |
0 commit comments