|
7 | 7 | type: choice
|
8 | 8 | description: Select type of deployment
|
9 | 9 | options:
|
| 10 | + - Release from Commit |
10 | 11 | - Major
|
11 | 12 | - Minor
|
12 | 13 | - Patch
|
13 |
| - - Release from Commit |
| 14 | + default: 'Release from Commit' |
14 | 15 | commit_hash:
|
15 | 16 | description: 'The hash of thee commit that should be deployed, defaults to the latest commit on main'
|
16 | 17 | required: false
|
|
39 | 40 | echo "deployment_type is ${{ github.event.inputs.deployment_type }}" / ${{ inputs.deployment_type }}
|
40 | 41 | echo "commit_hash is ${{ github.event.inputs.commit_hash }}" / ${{ inputs.commit_hash }}
|
41 | 42 |
|
| 43 | + verify-input: |
| 44 | + runs-on: ubuntu-24.04 |
| 45 | + steps: |
| 46 | + - name: Verify input |
| 47 | + run: | |
| 48 | + echo "deployment_type is ${{ github.event.inputs.deployment_type }}" / ${{ inputs.deployment_type }} |
| 49 | + echo "commit_hash is ${{ github.event.inputs.commit_hash }}" / ${{ inputs.commit_hash }} |
| 50 | + echo "deployment is ${{ github.event.inputs.deployment }}" / ${{ inputs.deployment }} |
42 | 51 | find-commit:
|
43 | 52 | runs-on: ubuntu-24.04
|
| 53 | + needs: verify-input |
44 | 54 | outputs:
|
45 | 55 | COMMIT_HASH: "${{ env.COMMIT_HASH }}"
|
46 | 56 | SHORT_COMMIT_HASH: "${{ env.SHORT_COMMIT_HASH }}"
|
@@ -175,6 +185,132 @@ jobs:
|
175 | 185 | name: okr-image
|
176 | 186 | path: /tmp/okr-docker-image.tar
|
177 | 187 |
|
| 188 | + e2e-docker: |
| 189 | + runs-on: ubuntu-24.04 |
| 190 | + needs: [ build-docker-image,update-version] |
| 191 | + strategy: |
| 192 | + fail-fast: false |
| 193 | + matrix: |
| 194 | + file: ${{ fromJSON('[login.cy.ts]') }} |
| 195 | + |
| 196 | + steps: |
| 197 | + - uses: actions/checkout@v4 |
| 198 | + |
| 199 | + - name: Download artifact |
| 200 | + uses: actions/download-artifact@v4 |
| 201 | + with: |
| 202 | + name: okr-image |
| 203 | + path: /tmp |
| 204 | + |
| 205 | + - name: Load image |
| 206 | + run: docker load --input /tmp/okr-docker-image.tar |
| 207 | + |
| 208 | + - name: Run keyloak server |
| 209 | + run: cd docker && docker compose up -d keycloak-pitc |
| 210 | + |
| 211 | + - name: run Springboot okr application |
| 212 | + run: | |
| 213 | + docker run --network=host \ |
| 214 | + -e SPRING_PROFILES_ACTIVE=integration-test \ |
| 215 | + ${{ needs.update-version.outputs.okr-docker-image}} & |
| 216 | +
|
| 217 | + - name: set node version |
| 218 | + uses: actions/setup-node@v4 |
| 219 | + with: |
| 220 | + node-version: ${{vars.NODE_VERSION}} |
| 221 | + |
| 222 | + - name: Cypress run e2e tests |
| 223 | + uses: cypress-io/github-action@v6 |
| 224 | + with: |
| 225 | + build: npm i -D cypress |
| 226 | + working-directory: frontend |
| 227 | + install: false |
| 228 | + wait-on: 'http://pitc.okr.localhost:8080/config, http://localhost:8544' |
| 229 | + wait-on-timeout: 120 |
| 230 | + browser: chrome |
| 231 | + headed: false |
| 232 | + config: baseUrl=http://pitc.okr.localhost:8080 |
| 233 | + spec: cypress/e2e/${{ matrix.file }} |
| 234 | + |
| 235 | + - uses: actions/upload-artifact@v4 |
| 236 | + if: always() |
| 237 | + with: |
| 238 | + name: cypress-screenshots for ${{ matrix.file }} |
| 239 | + path: frontend/cypress/screenshots |
| 240 | + |
| 241 | + |
| 242 | + upload-to-quay: |
| 243 | + runs-on: ubuntu-latest |
| 244 | + needs: [update-version, e2e-docker] #[e2e-docker, update-version] |
| 245 | + steps: |
| 246 | + - name: Checkout project |
| 247 | + uses: actions/checkout@v4 |
| 248 | + |
| 249 | + - name: Download artifact |
| 250 | + uses: actions/download-artifact@v4 |
| 251 | + with: |
| 252 | + name: okr-image |
| 253 | + path: /tmp |
| 254 | + |
| 255 | + - name: Load image |
| 256 | + run: docker load --input /tmp/okr-docker-image.tar |
| 257 | + |
| 258 | + - name: show images |
| 259 | + run: docker image ls -a |
| 260 | + |
| 261 | + - name: Log in to Quay registry |
| 262 | + uses: docker/login-action@v3 |
| 263 | + with: |
| 264 | + registry: ${{ secrets.QUAY_REGISTRY }} |
| 265 | + username: ${{ secrets.QUAY_USERNAME }} |
| 266 | + password: ${{ secrets.QUAY_TOKEN }} |
| 267 | + |
| 268 | + - name: Push |
| 269 | + run: docker push ${{ needs.update-version.outputs.okr-docker-image}} |
| 270 | + |
| 271 | + # - name: Install yq |
| 272 | + # shell: bash |
| 273 | + # env: |
| 274 | + # VERSION: v4.25.2 |
| 275 | + # BINARY: yq_linux_amd64 |
| 276 | + # run: | |
| 277 | + # wget -q https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - |\ |
| 278 | + # tar xz && mv ${BINARY} /usr/local/bin/yq |
| 279 | + |
| 280 | + deploy-release: |
| 281 | + runs-on: ubuntu-latest |
| 282 | + needs: |
| 283 | + - upload-to-quay |
| 284 | + steps: |
| 285 | + - uses: actions/checkout@v2 |
| 286 | + with: |
| 287 | + repository: ${{env.GITOPS_REPO}} |
| 288 | + token: secrets.GITLAB_ACCESS_TOKEN |
| 289 | + |
| 290 | + - uses: imranismail/setup-kustomize@v1 |
| 291 | + with: |
| 292 | + kustomize-version: 4.0.0 |
| 293 | + |
| 294 | + - run: kustomize edit set image ${{env.APP_IMAGE}}:${GITHUB_REF#refs/*/} |
| 295 | + working-directory: apps/${{env.APP_NAME}}/overlays/test |
| 296 | + |
| 297 | + - run: | |
| 298 | + git config user.email "[email protected]" |
| 299 | + git config user.name "gitops" |
| 300 | + git commit -am "Gitops update to $APP_NAME" |
| 301 | + git pull --rebase |
| 302 | + git push |
| 303 | + - name: Update YAML file |
| 304 | + shell: bash |
| 305 | + env: |
| 306 | + COMMITPREFIX: '[CTS]' |
| 307 | + run: | |
| 308 | + |
| 309 | + curl -s --header "PRIVATE-TOKEN: ${{}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}?ref=${{vars.TARGET_GITLAB_REFERENCE}}" -H "Accept: application/json" -H "Content-Type: application/json" | jq -r '.content' | base64 --decode > response.yaml |
| 310 | + yq -i "${{vars.YAML_PATH}} = \"${{needs.update-version.outputs.okr-docker-image}}\"" response.yaml |
| 311 | + UPDATED_CONTENT=$(cat response.yaml) |
| 312 | + curl --request PUT --header 'PRIVATE-TOKEN: ${{secrets.GITLAB_ACCESS_TOKEN}}' -F "branch=${{vars.TARGET_GITLAB_REFERENCE}}" -F "[email protected]" -F "author_name=GitLab Actions" -F "content=${UPDATED_CONTENT}" -F "commit_message=$COMMITPREFIX Automated changes to ${{vars.FILEPATH_COMMIT}}" "${{vars.TARGET_GITLAB_REPOSITORY}}/files/${{vars.GITLAB_FILEPATH}}" |
| 313 | +
|
178 | 314 | # create-release:
|
179 | 315 | # runs-on: ubuntu-24.04
|
180 | 316 | # needs: update-version
|
|
0 commit comments