Skip to content

Commit

Permalink
Refactor release workflow to notify Coolify for
Browse files Browse the repository at this point in the history
both Prod and Dev environments
  • Loading branch information
Geczy committed Dec 28, 2023
1 parent 20c8e33 commit 14eb24b
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@ name: Release to Coolify
on:
registry_package:
types: [published]

jobs:
release:
if: ${{ github.event.registry_package.package_version.container_metadata.labels.description != '' }}
environment: prod
runs-on: ubuntu-latest
environment: prod
steps:
- name: "Prod release"
- name: "Release to Prod and Dev"
run: |
# Map package name to UUID
case "${{ github.event.registry_package.name }}" in
"dota") UUID="i8gccg8" ;;
"twitch-events") UUID="zwg4g4c" ;;
"twitch-chat") UUID="zwgkg48" ;;
"steam") UUID="wsgwk8s" ;;
esac
notify_coolify() {
local env_name=$1
local uuid_map=$2
# Use curl to call a GET webhook with the mapped UUID and API key from secrets
curl -s -X GET -H "Authorization: Bearer ${{ secrets.COOLIFY_API_KEY }}" "https://${{ secrets.COOLIFY_HOST }}/api/v1/deploy?uuid=${UUID}&force=false"
# Map package name to UUID
case "${{ github.event.registry_package.name }}" in
"dota") UUID=${uuid_map["dota"]} ;;
"twitch-events") UUID=${uuid_map["twitch-events"]} ;;
"twitch-chat") UUID=${uuid_map["twitch-chat"]} ;;
"steam") UUID=${uuid_map["steam"]} ;;
esac
- name: "Dev release"
run: |
# Map package name to UUID
case "${{ github.event.registry_package.name }}" in
"dota") UUID="esgckgc" ;;
"twitch-events") UUID="kkk04os" ;;
"twitch-chat") UUID="qgosw80" ;;
"steam") UUID="q88g0c8" ;;
esac
# Notify Coolify
echo "Notifying Coolify for $env_name environment: $UUID"
curl -s -X GET -H "Authorization: Bearer ${{ secrets.COOLIFY_API_KEY }}" "https://${{ secrets.COOLIFY_HOST }}/api/v1/deploy?uuid=${UUID}&force=false"
}
# UUID mappings for prod and dev
declare -A prod_uuids=( ["dota"]="i8gccg8" ["twitch-events"]="zwg4g4c" ["twitch-chat"]="zwgkg48" ["steam"]="wsgwk8s" )
declare -A dev_uuids=( ["dota"]="esgckgc" ["twitch-events"]="kkk04os" ["twitch-chat"]="qgosw80" ["steam"]="q88g0c8" )
# Use curl to call a GET webhook with the mapped UUID and API key from secrets
curl -s -X GET -H "Authorization: Bearer ${{ secrets.COOLIFY_API_KEY }}" "https://${{ secrets.COOLIFY_HOST }}/api/v1/deploy?uuid=${UUID}&force=false"
# Notify for prod and dev
notify_coolify "Prod" prod_uuids
notify_coolify "Dev" dev_uuids

0 comments on commit 14eb24b

Please sign in to comment.