-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ddd5a8
commit f0e0644
Showing
3 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Push Image to Devtron | ||
|
||
on: [push] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Push Image to Devtron | ||
uses: ./ # Uses the local action defined in the repository | ||
with: | ||
DEVTRON_URL: ${{ secrets.DEVTRON_URL }} | ||
DEVTRON_API_TOKEN: ${{ secrets.DEVTRON_API_TOKEN }} | ||
IMAGE: ${{ secrets.IMAGE }} | ||
ID: ${{ secrets.ID }} | ||
COMMIT_HASH: ${{ secrets.COMMIT_HASH }} | ||
MESSAGE: ${{ secrets.MESSAGE }} | ||
AUTHOR_NAME: ${{ secrets.AUTHOR_NAME }} | ||
COMMIT_TIME: ${{ secrets.COMMIT_TIME }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: 'Devtron Deploy Action' | ||
description: 'An action to deploy using Devtron with optional commit details' | ||
author: 'Your Name' | ||
inputs: | ||
DEVTRON_URL: | ||
description: 'The URL of the Devtron instance' | ||
required: true | ||
DEVTRON_API_TOKEN: | ||
description: 'The API token for Devtron' | ||
required: true | ||
IMAGE: | ||
description: 'The Docker image to be deployed' | ||
required: true | ||
ID: | ||
description: 'The ID for the Devtron orchestrator' | ||
required: true | ||
COMMIT_HASH: | ||
description: 'The commit hash (optional)' | ||
required: false | ||
MESSAGE: | ||
description: 'The commit message (optional)' | ||
required: false | ||
AUTHOR_NAME: | ||
description: 'The author name of the commit (optional)' | ||
required: false | ||
COMMIT_TIME: | ||
description: 'The commit time (optional)' | ||
required: false | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- run: ./scripts/deploy.sh | ||
shell: bash | ||
env: | ||
DEVTRON_URL: ${{ inputs.DEVTRON_URL }} | ||
DEVTRON_API_TOKEN: ${{ inputs.DEVTRON_API_TOKEN }} | ||
IMAGE: ${{ inputs.IMAGE }} | ||
ID: ${{ inputs.ID }} | ||
COMMIT_HASH: ${{ inputs.COMMIT_HASH }} | ||
MESSAGE: ${{ inputs.MESSAGE }} | ||
AUTHOR_NAME: ${{ inputs.AUTHOR_NAME }} | ||
COMMIT_TIME: ${{ inputs.COMMIT_TIME }} | ||
branding: | ||
icon: 'rocket' | ||
color: 'blue' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
DEVTRON_URL=${DEVTRON_URL} | ||
DEVTRON_API_TOKEN=${DEVTRON_API_TOKEN} | ||
IMAGE=${IMAGE} | ||
ID=${ID} | ||
COMMIT_HASH=${COMMIT_HASH} | ||
MESSAGE=${MESSAGE} | ||
AUTHOR_NAME=${AUTHOR_NAME} | ||
COMMIT_TIME=${COMMIT_TIME} | ||
|
||
if [ -z "$COMMIT_HASH" ]; then | ||
COMMIT_HASH="" | ||
fi | ||
|
||
if [ -z "$MESSAGE" ]; then | ||
MESSAGE="" | ||
fi | ||
|
||
if [ -z "$AUTHOR_NAME" ]; then | ||
AUTHOR_NAME="" | ||
fi | ||
|
||
if [ -z "$COMMIT_TIME" ]; then | ||
COMMIT_TIME="" | ||
fi | ||
|
||
jsonData=$(cat <<EOF | ||
{ | ||
"dockerImage": "$IMAGE", | ||
"ciProjectDetails": [ | ||
{ | ||
"commitHash": "$COMMIT_HASH", | ||
"message": "$MESSAGE", | ||
"author": "$AUTHOR_NAME", | ||
"commitTime": "$COMMIT_TIME" | ||
} | ||
] | ||
} | ||
EOF | ||
) | ||
|
||
curl --location --request POST \ | ||
"https://${DEVTRON_URL}/orchestrator/webhook/ext-ci/${ID}" \ | ||
--header 'Content-Type: application/json' \ | ||
--header "api-token: ${DEVTRON_API_TOKEN}" \ | ||
--data-raw "${jsonData}" |