Skip to content

Undeploy PR

Undeploy PR #424

Workflow file for this run

name: PR Undeploy
run-name: Undeploy PR
description: |
This workflow is triggered manually via the workflow_dispatch event.
It removes the deployment and associated resources for the specified pull request in the development namespace.
on:
workflow_dispatch:
inputs:
pr-number:
description: Pull request number
required: true
type: string
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
remove-pr-dev:
name: Remove PR build from dev namespace
environment:
name: pr
runs-on: ubuntu-latest
timeout-minutes: 12
env:
ACRONYM: chefs
PR_NUMBER: ${{ github.event.inputs.pr-number || github.event.pull_request.number }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install OpenShift CLI (oc)
shell: bash
run: |
OC_VERSION="4.14.62"
OC_DIR="${HOME}/oc-bin"
mkdir -p "${OC_DIR}"
curl -sL "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OC_VERSION}/openshift-client-linux-${OC_VERSION}.tar.gz" | tar -xzf - -C "${OC_DIR}" oc
echo "${OC_DIR}" >> "${GITHUB_PATH}"
- name: Login to OpenShift Cluster
shell: bash
env:
OC_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }}
OC_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
OC_NAMESPACE: ${{ vars.NAMESPACE_PREFIX }}-dev
run: |
oc login --token="${OC_TOKEN}" --server="${OC_SERVER}" --insecure-skip-tls-verify
oc project "${OC_NAMESPACE}"
- name: Remove PR Deployment
shell: bash
run: |
oc delete deploymentconfig ${{ env.ACRONYM }}-app-pr-${{ env.PR_NUMBER }} -n ${{ vars.NAMESPACE_PREFIX }}-dev --ignore-not-found=true
oc delete -n ${{ vars.NAMESPACE_PREFIX }}-dev job pre-${{ env.ACRONYM }}-app-pr-${{ env.PR_NUMBER }} --ignore-not-found=true
oc delete -n ${{ vars.NAMESPACE_PREFIX }}-dev all,secret,networkpolicy,rolebinding --selector app=${{ env.ACRONYM }}-pr-${{ env.PR_NUMBER }}
oc delete -n ${{ vars.NAMESPACE_PREFIX }}-dev all,svc,cm,sa,role,secret --selector cluster-name=pr-${{ env.PR_NUMBER }}
- name: Remove Release Comment on PR
if: github.event_name == 'workflow_dispatch'
uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # SHA for v3
with:
header: release
delete: true
number: ${{ env.PR_NUMBER }}