|
3 | 3 | push: |
4 | 4 | tags: |
5 | 5 | - production_v* |
| 6 | +env: |
| 7 | + RELEASE_TYPE: Production |
6 | 8 | jobs: |
7 | 9 | build_and_publish: |
8 | 10 | name: Builds and Publishes to Cloudflare Pages Production |
|
25 | 27 | uses: ./.github/actions/versioning |
26 | 28 | with: |
27 | 29 | RELEASE_TAG: ${{ github.ref_name }} |
28 | | - RELEASE_TYPE: production |
| 30 | + RELEASE_TYPE: ${{ env.RELEASE_TYPE }} |
29 | 31 | - name: Extract version |
30 | 32 | id: extract_version |
31 | 33 | run: echo "RELEASE_VERSION=$(cat build/version)" >> $GITHUB_OUTPUT |
|
34 | 36 | with: |
35 | 37 | CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
36 | 38 | CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 39 | + - name: Upload Build Artifact |
| 40 | + uses: actions/upload-artifact@v4 |
| 41 | + with: |
| 42 | + name: build |
| 43 | + path: . |
| 44 | + retention-days: 1 |
| 45 | + |
| 46 | + send_slack_notification: |
| 47 | + name: Send Slack Notification |
| 48 | + environment: Production |
| 49 | + runs-on: ubuntu-latest |
| 50 | + if: always() |
| 51 | + needs: [build_and_publish] |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v4 |
| 55 | + - name: Conclusion |
| 56 | + uses: technote-space/workflow-conclusion-action@v3 |
| 57 | + - name: Create Slack Message |
| 58 | + id: create_slack_message |
| 59 | + run: | |
| 60 | + if [ "${{ env.WORKFLOW_CONCLUSION }}" == "success" ]; then |
| 61 | + echo "MESSAGE=${{ env.RELEASE_TYPE }} Release succeeded for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_ENV |
| 62 | + elif ["${{ env.WORKFLOW_CONCLUSION }}" == "failure"]; then |
| 63 | + echo "MESSAGE=${{ env.RELEASE_TYPE }} Release failed for api.deriv.com with version *${{ needs.build_and_publish.outputs.RELEASE_VERSION }}*" >> $GITHUB_ENV |
| 64 | + else |
| 65 | + echo "MESSAGE=Unkown outcome" >> $GITHUB_ENV |
| 66 | + fi |
| 67 | + - name: Send Slack Notification |
| 68 | + uses: ./.github/actions/notify_slack |
| 69 | + with: |
| 70 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 71 | + MESSAGE: ${{ steps.create_slack_message.outputs.MESSAGE }} |
| 72 | + |
| 73 | + build_and_publish_to_docker_k8s: |
| 74 | + name: Builds and Publishes image to Docker and Kubernetes |
| 75 | + runs-on: ubuntu-latest |
| 76 | + environment: Production |
| 77 | + needs: [build_and_publish] |
| 78 | + steps: |
| 79 | + - name: Download Build Artifact |
| 80 | + uses: actions/download-artifact@v4 |
| 81 | + with: |
| 82 | + name: build |
37 | 83 | - name: Publish to Docker |
| 84 | + id: publish_to_docker |
38 | 85 | uses: ./.github/actions/publish_to_docker |
39 | 86 | with: |
40 | 87 | DOCKER_LATEST_IMAGE_TAG: 'latest' |
|
43 | 90 | DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} |
44 | 91 | DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} |
45 | 92 | - name: Deploy to Kubernetes |
| 93 | + id: deploy_to_kubernetes |
46 | 94 | uses: ./.github/actions/deploy_to_kubernetes |
47 | 95 | with: |
48 | 96 | K8S_VERSION: ${{ github.ref_name }} |
|
51 | 99 | SERVICEACCOUNT_TOKEN: ${{ secrets.SERVICEACCOUNT_TOKEN }} |
52 | 100 | KUBE_SERVER: ${{ secrets.KUBE_SERVER }} |
53 | 101 | DOCKERHUB_ORGANISATION: ${{ secrets.DOCKERHUB_ORGANISATION }} |
54 | | - |
55 | | - send_slack_notification: |
56 | | - name: Send Slack Notification |
57 | | - environment: Production |
58 | | - runs-on: ubuntu-latest # TODO: Replace this with the appropriate runner for Deriv-Api-Docs when provided |
59 | | - if: always() |
60 | | - needs: |
61 | | - - build_and_publish |
62 | | - steps: |
63 | | - - name: Checkout |
64 | | - uses: actions/checkout@v4 |
65 | | - - name: Conclusion |
66 | | - uses: technote-space/workflow-conclusion-action@v3 |
67 | 102 | - name: Send Slack Notification |
| 103 | + if: ${{ steps.publish_to_docker.outcome != 'success' || steps.deploy_to_kubernetes.outcome != 'success' }} |
68 | 104 | uses: ./.github/actions/notify_slack |
69 | 105 | with: |
70 | | - RELEASE_TYPE: Production |
71 | | - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
72 | | - STATUS: ${{ env.WORKFLOW_CONCLUSION }} |
73 | | - version: ${{ needs.build_and_publish.outputs.RELEASE_VERSION}} |
| 106 | + RELEASE_TYPE: ${{ env.RELEASE_TYPE }} |
| 107 | + MESSAGE: "'${{ env.RELEASE_TYPE }}' Docker Publish and Kubernetes Deployment for api.deriv.com with version *'${{ needs.build_and_publish.outputs.RELEASE_VERSION }}'* has Failed *" |
0 commit comments