Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ on:

jobs:
dokploy_deploy:
uses: jmischler72/dokploy-deploy-actions@main
uses: tawandachiteshe/dokploy-deploy-actions@main
with:
PROJECT_NAME: project-name
APPLICATION_NAME: application-name
DOKPLOY_HOST: ${{ secrets.DOKPLOY_HOST }}
DOKPLOY_TOKEN: ${{ secrets.DOKPLOY_TOKEN }}
PROJECT_NAME: "Project Name"
APPLICATION_NAME: "Application Name"
DOKPLOY_URL: ${{ secrets.DOKPLOY_URL }}
DOKPLOY_API_KEY: ${{ secrets.DOKPLOY_API_KEY }}
ENVIROMENT_NAME: production

```

Expand All @@ -36,4 +37,5 @@ jobs:
- `PROJECT_NAME`: The name of the project in which the application you want to deploy is in
- `APPLICATION_NAME`: The name of the application you want to deploy
- `DOKPLOY_HOST`: The host ip or domain of your dokploy instance.
- `DOKPLOY_TOKEN`: Create an API token in your profile settings on Dokploy
- `DOKPLOY_TOKEN`: Create an API token in your profile settings on Dokploy
- `ENVIROMENT_NAME`: The name of the environment you want to deploy to
96 changes: 61 additions & 35 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,67 @@
name: "Dokploy Deploy Action"
name: "Tawanda Chiteshe Dokploy Deploy Action"
description: "Deploy an application to Dokploy"
author: "jmischler72"
author: "tawandachiteshe"
inputs:
APPLICATION_NAME:
description: "The name of the application to deploy"
required: true
default: "application"
PROJECT_NAME:
description: "The name of the project to deploy"
required: true
default: "project"
DOKPLOY_HOST:
description: "The host of the Dokploy instance"
required: true
DOKPLOY_TOKEN:
description: "The token to authenticate with Dokploy"
required: true

runs:
using: "composite"
steps:
- name: Retrieve application id
id: retrieve-application-id
run: |
PROJECT_LIST=$(curl -X 'GET' 'https://${{ secrets.DOKPLOY_HOST }}/api/project.all' -H 'accept: application/json' -H 'Authorization: Bearer ${{ secrets.DOKPLOY_TOKEN }}')
echo "::add-mask::$PROJECT_LIST"
echo "APPLICATION_ID=$(echo $PROJECT_LIST | jq -r '.[] | select(.name == "${{ inputs.PROJECT_NAME }}") | .applications[] | select(.name == "${{ inputs.APPLICATION_NAME }}") | .applicationId')" >> "$GITHUB_OUTPUT"
DOKPLOY_URL:
description: "The URL of the Dokploy instance"
required: true
default: "dokploy.com"
DOKPLOY_API_KEY:
description: "The API key to authenticate with Dokploy"
required: true
APPLICATION_NAME:
description: "The name of the application to deploy"
required: true
default: "application"
PROJECT_NAME:
description: "The name of the project to deploy"
required: true
default: "project"
ENVIROMENT_NAME:
description: "The name of the project to deploy"
required: true
default: "production"
DOKPLOY_HOST:
description: "The host of the Dokploy instance"
required: true
DOKPLOY_TOKEN:
description: "The token to authenticate with Dokploy"
required: true

- name: Deploy to Dokploy
run: |
curl -X 'POST' \
'https://${{ secrets.DOKPLOY_HOST }}/api/application.deploy' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer ${{ secrets.DOKPLOY_TOKEN }}" \
-d '{ "applicationId": "${{ steps.retrieve-application-id.outputs.APPLICATION_ID }}" }'
runs:
using: "composite"
steps:
- name: Install JQ
shell: bash
run: |
if ! command -v jq &>/dev/null; then
sudo apt-get -qq update
sudo apt-get -qq install -y jq
fi
- name: Retrieve Application ID
shell: bash
id: retrieve-application-id
run: |
PROJECT_LIST=$(curl -X 'GET' 'https://${{ inputs.DOKPLOY_URL }}/api/project.all' -H 'accept: application/json' -H 'x-api-key: ${{ inputs.DOKPLOY_API_KEY }}')
echo "::add-mask::$PROJECT_LIST"
echo "APPLICATION_ID=$(echo $PROJECT_LIST | jq -r '.[] | select(.name == "${{ inputs.PROJECT_NAME }}") | .environments[] | select(.name == "${{ inputs.ENVIROMENT_NAME }}") | .applications[] | select(.name == "${{ inputs.APPLICATION_NAME }}") | .applicationId')" >> "$GITHUB_OUTPUT"
- name: Get Last Commit Message
id: last-commit-message
shell: bash
run: |
LAST_COMMIT_MESSAGE="$(git log -1 --pretty=format:%s)"
echo "LAST_COMMIT_MESSAGE=${LAST_COMMIT_MESSAGE}" >> "$GITHUB_OUTPUT"
- name: Deploy to Dokploy
shell: bash
run: |
curl -X 'POST' \
'https://${{inputs.DOKPLOY_URL}}/api/application.deploy' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H "x-api-key: ${{ inputs.DOKPLOY_API_KEY }}" \
-d '{ "applicationId": "${{ steps.retrieve-application-id.outputs.APPLICATION_ID }}", "title": "${{ steps.last-commit-message.outputs.LAST_COMMIT_MESSAGE }}", "description": "${{ github.sha }}" }'

branding:
icon: "box"
color: "gray-dark"
color: "gray-dark"