Skip to content

chore: Add Preview Environments to Connectors #4

chore: Add Preview Environments to Connectors

chore: Add Preview Environments to Connectors #4

---
name: preview-env-teardown
on:
pull_request:
types: [ unlabeled,closed ]
jobs:
teardown-preview:
# check whether the unlabel name was deploy-preview || check whether the PR was closed / merged and whether deploy-preview was part of the array
if: github.event.label.name == 'deploy-preview' || (github.event.action == 'closed' && contains( github.event.pull_request.labels.*.name, 'deploy-preview') )
runs-on: ubuntu-22.04
timeout-minutes: 20
env:
BRANCH_NAME: ${{ github.head_ref }} # head_ref = branch on PR
strategy:
fail-fast: false # Don't disrupt other deployments because of failure
matrix:
product_context: [c8sm]
steps:
#########################################################################
# Sanitize the branch name to remove dependabot/,renovate/ and transform the name
- id: sanitize
uses: camunda/infra-global-github-actions/sanitize-branch-name@main
with:
branch: ${{ env.BRANCH_NAME }}
max_length: '15'
#########################################################################
# Setup: import secrets from vault
- name: Import secrets
id: secrets
uses: hashicorp/vault-action@affa6f04da5c2d55e6e115b7d1b044a6b1af8c74 # v2.7.4
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
secrets: |
secret/data/products/connectors/ci/common ARGOCD_TOKEN;
#########################################################################
# Setup: checkout code. This is required because we are using
# composite actions and deployment manifests.
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
#########################################################################
# Tear down preview environment
- name: Tear down Preview Environment for ${{ matrix.product_context }}
uses: camunda/infra-global-github-actions/preview-env/destroy@main
with:
revision: ${{ env.BRANCH_NAME }}
argocd_token: ${{ steps.secrets.outputs.ARGOCD_TOKEN }}
app_name: connectors-${{ steps.sanitize.outputs.branch_name }}-${{ matrix.product_context }}
clean:
if: always() && needs.teardown-preview.result != 'skipped'
uses: camunda/connectors/.github/workflows/PREVIEW-ENV-CLEAN.yml@infra-gh-510-preview-environments
needs: [teardown-preview]
secrets: inherit
with:
pull-request: ${{ github.event.pull_request.number }}