Skip to content

OCT-1400 Add Ackee to the client #60

OCT-1400 Add Ackee to the client

OCT-1400 Add Ackee to the client #60

Workflow file for this run

---
name: 🔒 Destroy Environment
on:
workflow_call:
inputs:
env-type:
required: true
type: string
pull-request-id:
required: false
type: string
workflow-id:
required: false
type: string
delete-env:
required: false
default: true
type: boolean
pull_request:
types: [ closed ]
env:
# ----------------------------------------------------------------------------
# CI/CD
HOUSEKEEPER_NAME: "${{ vars.HOUSEKEEPER_NAME }}"
HOUSEKEEPER_EMAIL: "${{ secrets.HOUSEKEEPER_EMAIL }}"
HOUSEKEEPER_CI_TOKEN: "${{ secrets.HOUSEKEEPER_CI_TOKEN }}"
HOUSEKEEPER_GPG_KEY: "${{ secrets.HOUSEKEEPER_GPG_KEY }}"
HOUSEKEEPER_GPG_KEY_ID: "${{ secrets.HOUSEKEEPER_GPG_KEY_ID }}"
ARGOCD_URL: "${{ secrets.ARGOCD_URL }}"
ARGOCD_ACCESS_TOKEN: "${{ secrets.ARGOCD_ACCESS_TOKEN }}"
jobs:
destroy:
name: Destroy Environment
runs-on:
- metal
container:
image: registry.gitlab.com/golemfoundation/devops/container-builder/gitops-builder:2ea6d57c
credentials:
username: "doesnt-matter"
password: "${{ secrets.GITLAB_PAT_CONTAINER_BUILDER_DOCKER_IMAGES_READ }}"
steps:
- uses: actions/[email protected]
- name: Set up Gitops mutex
uses: ben-z/[email protected]
with:
branch: gitops-mutex
- name: Destroy application
id: destroy-env
run: |
set -ex
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
export ENV_TYPE=${{ inputs.env-type }}
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
export CI_MERGE_REQUEST_IID=${{ github.event.number }}
export CI_PIPELINE_ID=${{ github.run_id }}
else
export CI_MERGE_REQUEST_IID=${{ inputs.pull-request-id }}
export CI_PIPELINE_ID=${{ inputs.workflow-id }}
fi
source ${CI_PROJECT_DIR}/ci/argocd/resolve_env.sh $ENV_TYPE
bash ${CI_PROJECT_DIR}/ci/argocd/application.sh destroy
echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_OUTPUT
shell: bash
- uses: actions/github-script@v7
id: does-env-exist
if: always()
with:
result-encoding: string
script: |
try {
await github.rest.repos.getEnvironment({
owner: context.repo.owner,
repo: context.repo.repo,
environment_name: '${{ steps.destroy-env.outputs.DEPLOYMENT_ID }}',
});
return 'true';
} catch {
return 'false';
}
- name: Delete Environment
uses: bobheadxi/deployments@v1
if: ${{ (steps.does-env-exist.outputs.result == 'true') && (inputs.delete-env || github.event_name == 'pull_request') }}
with:
step: delete-env
token: ${{ secrets.GH_BOT_TOKEN }}
env: ${{ steps.destroy-env.outputs.DEPLOYMENT_ID }}
- name: Deactivate Environment
uses: bobheadxi/deployments@v1
if: ${{ (steps.does-env-exist.outputs.result == 'true') && !inputs.delete-env }}
with:
step: deactivate-env
token: ${{ secrets.GH_BOT_TOKEN }}
env: ${{ steps.destroy-env.outputs.DEPLOYMENT_ID }}