Delete Application In Humanitec
Overviewโ
This self service guide provides a comprehensive walkthrough on how to delete an application in Humanitec from Port using Port's self service actions.
- Port's GitHub app needs to be installed.
- In your GitHub repository, go to Settings > Secrets and add the following secrets:
- HUMANITEC_API_KEY- Humanitec API Key
- HUMANITEC_ORG_ID- Humanitec Organization ID
- PORT_CLIENT_ID- Your port- client idHow to get the credentials.
- PORT_CLIENT_SECRET- Your port- client secretHow to get the credentials.
 
- Optional - Install Port's Humanitec integration learn more
This step is not required for this example, but it will create all the blueprint boilerplate for you, and also ingest and update the catalog in real time with your Humanitec Application.
Humanitec Application Blueprint (Click to expand)
{
  "identifier": "humanitecApplication",
  "description": "Humanitec Application",
  "title": "humanitecApplication",
  "icon": "Apps",
  "schema": {
    "properties": {
      "createdAt": {
        "type": "string",
        "title": "Created At",
        "format": "date-time"
      }
    },
    "required": []
  },
  "mirrorProperties": {},
  "calculationProperties": {},
  "aggregationProperties": {},
  "relations": {}
}
GitHub Workflowโ
Create the file .github/workflows/delete-humanitec-application.yaml in the .github/workflows folder of your repository.
We recommend creating a dedicated repository for the workflows that are used by Port actions.
GitHub Workflow
name: Delete Humanitec Application
on:
  workflow_dispatch:
    inputs:
      port_context:
        required: true
        description: includes blueprint, run ID, and entity identifier from Port.
jobs:
  delete-application:
    runs-on: ubuntu-latest
    steps:
      - name: Delete Application
        uses: fjogeleit/http-request-action@v1
        with:
          url: 'https://api.humanitec.io/orgs/${{secrets.HUMANITEC_ORG_ID}}/apps/${{fromJson(inputs.port_context).entity}}'
          method: 'DELETE'
          customHeaders: '{"Content-Type": "application/json", "Authorization": "Bearer ${{ secrets.HUMANITEC_API_KEY }}"}'
      - name: Log Delete Application Request Failure 
        if: failure()
        uses: port-labs/port-github-action@v1
        with:
          clientId: ${{ secrets.PORT_CLIENT_ID }}
          clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
          baseUrl: https://api.getport.io
          operation: PATCH_RUN
          runId: ${{fromJson(inputs.port_context).run_id}}
          logMessage: "Request to delete application failed ..."
      - name: Log Delete Application Request Success
        uses: port-labs/port-github-action@v1
        with:
          clientId: ${{ secrets.PORT_CLIENT_ID }}
          clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
          baseUrl: https://api.getport.io
          operation: PATCH_RUN
          runId: ${{fromJson(inputs.port_context).run_id}}
          logMessage: |
             Humanitech application has been successfully deleted! โ
             Deleting entity from port
      - name: Get Port Token
        id: port_access_token
        uses: fjogeleit/http-request-action@v1
        with:
          url: 'https://api.getport.io/v1/auth/access_token'
          method: 'POST'
          customHeaders: '{"Content-Type": "application/json", "accept": "application/json"}'
          data: |
            {
              "clientId": "${{ secrets.PORT_CLIENT_ID }}",
              "clientSecret": "${{ secrets.PORT_CLIENT_SECRET }}"
            }
          
      - name: Delete Application From Port
        uses: fjogeleit/http-request-action@v1
        with:
          url: 'https://api.getport.io/v1/blueprints/${{fromJson(inputs.port_context).blueprint}}/entities/${{fromJson(inputs.port_context).entity}}?delete_dependents=false'
          method: 'DELETE'
          customHeaders: '{"Content-Type": "application/json", "Authorization": "Bearer ${{ fromJson(steps.port_access_token.outputs.response).accessToken }}"}'
  
      - name: Log Delete Application From Port Request Failure 
        if: failure()
        uses: port-labs/port-github-action@v1
        with:
          clientId: ${{ secrets.PORT_CLIENT_ID }}
          clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
          baseUrl: https://api.getport.io
          operation: PATCH_RUN
          runId: ${{fromJson(inputs.port_context).run_id}}
          logMessage: "Request to delete application failed ..."
          
      - name: Log Delete Application Entity From Port
        uses: port-labs/port-github-action@v1
        with:
          clientId: ${{ secrets.PORT_CLIENT_ID }}
          clientSecret: ${{ secrets.PORT_CLIENT_SECRET }}
          baseUrl: https://api.getport.io
          operation: PATCH_RUN
          runId: ${{fromJson(inputs.port_context).run_id}}
          logMessage: |
              Application has been successfully deleted from port โ
Port Configurationโ
Create a new self service action using the following JSON configuration.
Delete application In Humanitec (click to expand)
Make sure to replace <GITHUB_ORG> and <GITHUB_REPO> with your GitHub organization and repository names respectively.
{
  "identifier": "delete_application",
  "title": "Delete Application",
  "icon": "Microservice",
  "description": "Delete an application on humanitec",
  "trigger": {
    "type": "self-service",
    "operation": "DELETE",
    "userInputs": {
      "properties": {},
      "required": [],
      "order": []
    },
    "blueprintIdentifier": "humanitecApplication"
  },
  "invocationMethod": {
    "type": "GITHUB",
    "org": "<GITHUB_ORG>",
    "repo": "<GITHUB_REPO>",
    "workflow": "delete-humanitec-application.yaml",
    "workflowInputs": {
      "port_context": {
        "entity": "{{.entity.identifier}}",
        "blueprint": "{{.action.blueprint}}",
        "run_id": "{{.run.id}}",
        "relations": "{{.entity.relations}}"
      }
    },
    "reportWorkflowStatus": true
  },
  "requiredApproval": false
}
Now you should see the Delete Application action in the self-service page. ๐
Let's test it!โ
- Go to the Self Service page of your portal.
- Click on the Delete Applicationaction
- Choose the humanitec application you want to delete (In case you didn't install the Humanitec integration, it means you don't have any Humanitec applications in Port yet, so you will need to create one manually in Port to test this action)
- Click on Execute
- Done! wait for the application to be deleted in Humanitec