|
| 1 | +name: Test, Build, and Publish to Stage Environment |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +jobs: |
| 9 | + run-code-lint: |
| 10 | + name: Code Lint 🧹 |
| 11 | + runs-on: default |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v5 |
| 14 | + name: Checkout Repo |
| 15 | + - uses: ./.github/actions/code-lint |
| 16 | + name: Code Lint |
| 17 | + |
| 18 | + run-unit-tests: |
| 19 | + name: Unit Testing 🧪 |
| 20 | + runs-on: default |
| 21 | + permissions: |
| 22 | + id-token: write |
| 23 | + contents: read |
| 24 | + steps: |
| 25 | + - name: Get GH app token |
| 26 | + id: gh-app-token |
| 27 | + uses: cloudbeds/composite-actions/gh-app-token@v2 |
| 28 | + with: |
| 29 | + # replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app |
| 30 | + repositories: >- |
| 31 | + ["<argocd-replace-with-your-repo>"] |
| 32 | + # replace <placeholders with your project/squad GH app details> |
| 33 | + app_name: <github-app-name> |
| 34 | + |
| 35 | + - uses: actions/checkout@v5 |
| 36 | + name: Checkout Repo |
| 37 | + - uses: ./.github/actions/unit-tests |
| 38 | + name: Run Unit Tests |
| 39 | + env: |
| 40 | + GITHUB_ACCESS_TOKEN: ${{ steps.gh-app-token.outputs.github-token }} |
| 41 | + |
| 42 | + build-push: |
| 43 | + if: 0 # remove this line to enable this job |
| 44 | + name: Build and push image 🧱 |
| 45 | + needs: |
| 46 | + - "run-unit-tests" |
| 47 | + - "run-code-lint" |
| 48 | + uses: ./.github/workflows/docker-build.yaml |
| 49 | + secrets: inherit |
| 50 | + with: |
| 51 | + push: true |
| 52 | + |
| 53 | + update-deployment: |
| 54 | + if: 0 # remove this line to enable this job |
| 55 | + name: Triggers action to update ArgoCD application deployment manifest with new image tag |
| 56 | + needs: build-push |
| 57 | + runs-on: x1-core |
| 58 | + permissions: |
| 59 | + id-token: write |
| 60 | + contents: read |
| 61 | + steps: |
| 62 | + |
| 63 | + - name: Get GH app token |
| 64 | + id: gh-app-token |
| 65 | + uses: cloudbeds/composite-actions/gh-app-token@v2 |
| 66 | + with: |
| 67 | + # replace <argocd-replace-with-your-repo> with the name of the argocd-repo that deploys your app |
| 68 | + repositories: >- |
| 69 | + ["<argocd-replace-with-your-repo>"] |
| 70 | + # replace <placeholders with your project/squad GH app details> |
| 71 | + app_name: <github-app-name> |
| 72 | + |
| 73 | + - name: Update application on stage cluster |
| 74 | + |
| 75 | + with: |
| 76 | + owner: cloudbeds |
| 77 | + repo: argocd-${REPLACE_ME_WITH_YOUR_ARGO} |
| 78 | + github_token: ${{ steps.gh-app-token.outputs.github-token }} |
| 79 | + workflow_file_name: update-application.yaml |
| 80 | + client_payload: | |
| 81 | + { |
| 82 | + "cluster": "stage-ga", |
| 83 | + "app_name": "${{ github.event.repository.name }}", |
| 84 | + "image_tag": "${{ github.sha }}" |
| 85 | + } |
0 commit comments