feat: add test and production deployment steps to CI workflow #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # CI/CD workflow for core-geonetwork (MetaSpace) | |
| # | |
| # Build Strategy: | |
| # - On push to metaspace branch: builds and pushes images to Artifactory | |
| # - Triggers k8s-apps-config pipeline to update manifests | |
| # - ArgoCD syncs the updated manifests to the cluster | |
| # | |
| # This workflow triggers a Bitbucket pipeline to update the GitOps repository. | |
| name: CI/CD | |
| on: | |
| push: | |
| branches: [metaspace] | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| build: | |
| uses: manaakiwhenua/github-workflows/.github/workflows/docker-build.yml@main | |
| with: | |
| bake_file: docker-bake.hcl | |
| bake_target: default | |
| image_name: metaspace | |
| push: ${{ github.event_name != 'pull_request' }} | |
| registry_host: ${{ vars.ARTIFACTORY_HOST }} | |
| registry_username: ${{ vars.ARTIFACTORY_USERNAME }} | |
| secrets: | |
| ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }} | |
| REGISTRY_CA_CERT: ${{ secrets.REGISTRY_CA_CERT }} | |
| deploy-dev: | |
| needs: build | |
| if: github.ref == 'refs/heads/metaspace' | |
| runs-on: ubuntu-latest | |
| environment: k8s-dev | |
| steps: | |
| - name: Checkout for action | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: manaakiwhenua/github-workflows | |
| sparse-checkout: actions/k8s-deploy | |
| path: .github-workflows | |
| - name: Deploy to dev | |
| uses: ./.github-workflows/actions/k8s-deploy | |
| with: | |
| app_name: metaspace | |
| environment: dev | |
| cluster: tak-k8s-nonprod | |
| build_key: ${{ needs.build.outputs.build_id }} | |
| bitbucket_token: ${{ secrets.K8S_APPS_CONFIG_TRIGGER_TOKEN }} | |
| - name: Deployment Summary | |
| run: | | |
| cat << SUMMARY >> $GITHUB_STEP_SUMMARY | |
| ## ✅ Dev Deployment Triggered | |
| | Property | Value | | |
| |----------|-------| | |
| | Build ID | \`${{ needs.build.outputs.build_id }}\` | | |
| | Environment | dev | | |
| | Cluster | tak-k8s-nonprod | | |
| The k8s-apps-config pipeline has updated the manifests and ArgoCD will sync shortly. | |
| ### Next Steps | |
| To promote to **test** or **production**, go to the workflow run and approve the pending deployment. | |
| SUMMARY | |
| deploy-test: | |
| needs: build | |
| if: github.ref == 'refs/heads/metaspace' | |
| runs-on: ubuntu-latest | |
| environment: k8s-test # Configure required reviewers in GitHub repo settings | |
| steps: | |
| - name: Checkout for action | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: manaakiwhenua/github-workflows | |
| sparse-checkout: actions/k8s-deploy | |
| path: .github-workflows | |
| - name: Deploy to test | |
| uses: ./.github-workflows/actions/k8s-deploy | |
| with: | |
| app_name: metaspace | |
| environment: test | |
| cluster: tak-k8s-nonprod | |
| build_key: ${{ needs.build.outputs.build_id }} | |
| bitbucket_token: ${{ secrets.K8S_APPS_CONFIG_TRIGGER_TOKEN }} | |
| - name: Deployment Summary | |
| run: | | |
| cat << SUMMARY >> $GITHUB_STEP_SUMMARY | |
| ## ✅ Test Deployment Triggered | |
| | Property | Value | | |
| |----------|-------| | |
| | Build ID | \`${{ needs.build.outputs.build_id }}\` | | |
| | Environment | test | | |
| | Cluster | tak-k8s-nonprod | | |
| SUMMARY | |
| deploy-prod: | |
| needs: build | |
| if: github.ref == 'refs/heads/metaspace' | |
| runs-on: ubuntu-latest | |
| environment: k8s-prod # Configure required reviewers in GitHub repo settings | |
| steps: | |
| - name: Checkout for action | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: manaakiwhenua/github-workflows | |
| sparse-checkout: actions/k8s-deploy | |
| path: .github-workflows | |
| - name: Deploy to prod | |
| uses: ./.github-workflows/actions/k8s-deploy | |
| with: | |
| app_name: metaspace | |
| environment: prod | |
| cluster: tak-k8s-prod | |
| build_key: ${{ needs.build.outputs.build_id }} | |
| bitbucket_token: ${{ secrets.K8S_APPS_CONFIG_TRIGGER_TOKEN }} | |
| - name: Deployment Summary | |
| run: | | |
| cat << SUMMARY >> $GITHUB_STEP_SUMMARY | |
| ## ✅ Production Deployment Triggered | |
| | Property | Value | | |
| |----------|-------| | |
| | Build ID | \`${{ needs.build.outputs.build_id }}\` | | |
| | Environment | prod | | |
| | Cluster | tak-k8s-prod | | |
| SUMMARY | |