Embed Application Catalog #458
Workflow file for this run
This file contains 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
name: Undeploy | |
on: | |
pull_request: | |
types: | |
- closed | |
env: | |
ENVIRONMENT: preview | |
OPENSHIFT_API: https://api.cloudscale-lpg-2.appuio.cloud:6443 | |
HELM_RELEASE_NAME: portal-pr-${{ github.event.number }} | |
IMG_TAG: pr-${{ github.event.number }} | |
NAMESPACE: appuio-control-api-preview | |
IMAGE_NAME: cloud-portal | |
jobs: | |
uninstall: | |
runs-on: ubuntu-latest | |
if: ${{ !startsWith(github.head_ref, 'renovate/') }} | |
environment: preview | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup helmfile | |
uses: mamezou-tech/[email protected] | |
with: | |
helm-version: v3.11.2 | |
helmfile-version: v0.152.0 | |
install-kubectl: false | |
additional-helm-plugins: https://github.com/aslafy-z/helm-git --version 0.15.1 | |
- name: Install CLI tools from OpenShift Mirror | |
uses: redhat-actions/openshift-tools-installer@v1 | |
with: | |
oc: "4" | |
- name: Authenticate and set context | |
uses: redhat-actions/oc-login@v1 | |
with: | |
openshift_server_url: ${{ env.OPENSHIFT_API }} | |
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }} | |
namespace: ${{ env.NAMESPACE }} | |
# We don't have a LE cert yet | |
insecure_skip_tls_verify: true | |
- name: Gather deployment status | |
id: deployment_info | |
run: | | |
echo route_host="$(oc -n ${{ env.NAMESPACE }} get route ${{ env.HELM_RELEASE_NAME }} -o jsonpath='{.spec.host}')" >> $GITHUB_OUTPUT | |
- name: Uninstall app | |
run: helmfile --namespace ${{ env.NAMESPACE }} --file deployment/helmfile.yaml -e ${{ env.ENVIRONMENT }} destroy --args --wait | |
env: | |
HELM_RELEASE_NAME: ${{ env.HELM_RELEASE_NAME }} | |
IMG_TAG: none | |
- name: Delete image in registry | |
run: oc -n ${{ env.NAMESPACE }} delete imagestreamtags ${{ env.IMAGE_NAME }}:${{ env.IMG_TAG }} --ignore-not-found | |
- name: Remove route URL from Keycloak client | |
run: .github/keycloak-redirect-url.sh "${{ secrets.KEYCLOAK_USER }}" "${{ secrets.KEYCLOAK_PASSWORD }}" "https://${{ steps.deployment_info.outputs.route_host }}/*" remove | |
- name: Notify on success | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.number }} | |
body: | | |
## ✔️ Preview deployment uninstalled | |
| | | | |
|-|-| | |
**Helm release** | ${{ env.NAMESPACE }}/${{ env.HELM_RELEASE_NAME }} | |
**Cluster** | ${{ env.OPENSHIFT_API }} | |
- name: Notify on failure | |
uses: peter-evans/create-or-update-comment@v3 | |
if: ${{ failure() }} | |
with: | |
issue-number: ${{ github.event.number }} | |
body: | | |
## ❌ Failed to remove preview deployment | |
| | | | |
|-|-| | |
**Helm release** | ${{ env.NAMESPACE }}/${{ env.HELM_RELEASE_NAME }} | |
**Cluster** | ${{ env.OPENSHIFT_API }} | |
Please investigate what went wrong in the GitHub actions logs. | |
Maintainers can manually remove the deployment by running | |
```bash | |
helmfile -n ${{ env.NAMESPACE }} -f deployment/helmfile.yaml -e ${{ env.ENVIRONMENT }} destroy | |
oc -n ${{ env.NAMESPACE }} delete imagestreamtags ${{ env.IMAGE_NAME }}:${{ env.IMG_TAG }} --ignore-not-found | |
``` |