Deploy Application In Humanitec
Overviewโ
This self service guide provides a comprehensive walkthrough on how to deploy 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 KeyHUMANITEC_ORG_ID
- Humanitec Organization IDPORT_CLIENT_ID
- Your portclient id
How to get the credentials.PORT_CLIENT_SECRET
- Your portclient secret
How 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
{
"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/deploy-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: Deploy Humanitec Application
on:
workflow_dispatch:
inputs:
delta_id:
type: string
description: The Delta ID
required: true
comment:
type: string
description: An optional comment to help communicate the purpose of the Deployment.
required: false
environment:
type: string
description: The Environment ID
required: true
port_context:
required: true
description: includes blueprint, run ID, and entity identifier from Port.
jobs:
deploy-application:
runs-on: ubuntu-latest
steps:
- name: Deploy Application
uses: fjogeleit/http-request-action@v1
with:
url: 'https://api.humanitec.io/orgs/${{secrets.HUMANITEC_ORG_ID}}/apps/${{fromJson(inputs.port_context).entity}}/envs/${{inputs.environment}}/deploys'
method: 'POST'
customHeaders: '{"Content-Type": "application/json", "Authorization": "Bearer ${{ secrets.HUMANITEC_API_KEY }}"}'
- name: Log Deploy 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: "Failed to deploy application ..."
- name: Log Deploy 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: |
Application has been successfully deployed ! โ
Port Configurationโ
Create a new self service action using the following JSON configuration.
Deploy application In Humanitec (click to expand)
Make sure to replace <GITHUB_ORG>
and <GITHUB_REPO>
with your GitHub organization and repository names respectively.
{
"identifier": "deploy_application",
"title": "Deploy Application",
"icon": "Microservice",
"description": "Deploy humanitec Application",
"trigger": {
"type": "self-service",
"operation": "DAY-2",
"userInputs": {
"properties": {
"delta_id": {
"type": "string",
"title": "Delta ID",
"description": "Delta ID",
"icon": "Deployment"
},
"comment": {
"type": "string",
"description": "Comment on the deployment",
"title": "Comment"
},
"environment": {
"type": "string",
"title": "Environment",
"description": "Deployment environment ID",
"blueprint": "humanitecEnvironment",
"format": "entity"
}
},
"required": [
"delta_id"
],
"order": [
"delta_id",
"comment"
]
},
"blueprintIdentifier": "humanitecApplication"
},
"invocationMethod": {
"type": "GITHUB",
"org": "<GITHUB_ORG>",
"repo": "<GITHUB_REPO>",
"workflow": "deploy-humanitec-application.yaml",
"workflowInputs": {
"delta_id": "{{ .inputs.\"delta_id\" }}",
"comment": "{{ .inputs.\"comment\" }}",
"port_context": {
"blueprint": "{{.action.blueprint}}",
"entity": "{{.entity.identifier}}",
"run_id": "{{.run.id}}"
}
},
"reportWorkflowStatus": true
},
"requiredApproval": false
}
Now you should see the Deploy Application
action in the self-service page. ๐
Let's test it!โ
- Go to the Self Service page of your portal.
- Click on the
Deploy Application
action - Choose the humanitec application you want to deploy (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)
- Select the new application
- Enter the
Delta ID
of the deployment, select anEnvironment
you want to deploy to and briefComment
about the deployment. - Click on
Execute
- Done! wait for the application to be deployed in Humanitec
Congrats ๐ You've deployed a Humanitec application in Port ๐ฅ