diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml index abba1b26..0455b98e 100644 --- a/.github/workflows/builder.yml +++ b/.github/workflows/builder.yml @@ -7,24 +7,26 @@ on: jobs: build: runs-on: ubuntu-latest + environment: prod permissions: packages: write steps: - uses: actions/checkout@v4 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Login to ghcr uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ secrets.GHA_PAT }} - name: Build and push uses: docker/bake-action@v4 with: push: true - sbom: false provenance: false set: | *.platform=linux/arm64 diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 735b82a4..5f43d33c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,31 +1,38 @@ -name: Map and Notify On Registry Package Update +name: Release to Coolify on: registry_package: - types: [updated] + types: [published] jobs: - notify: + release: + if: ${{ github.event.registry_package.package_version.container_metadata.labels.description != '' }} runs-on: ubuntu-latest + environment: prod steps: - - name: Check for image tag information and valid package name - if: | - github.event.registry_package.package_version.container_metadata.tag.name != '' && - ( - github.event.registry_package.name == 'dota' || - github.event.registry_package.name == 'twitch-events' || - github.event.registry_package.name == 'twitch-chat' || - github.event.registry_package.name == 'steam' - ) - + - name: "Release to Prod and Dev" run: | - # Map package name to UUID - case "${{ github.event.registry_package.name }}" in - "dota") UUID="esgckgc" ;; - "twitch-events") UUID="aopskdk" ;; - "twitch-chat") UUID="gahgag" ;; - "steam") UUID="asldja" ;; - esac + notify_coolify() { + local env_name=$1 + local uuid_map=$2 + + # 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 + + # 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 -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 diff --git a/docker-compose.yml b/docker-compose.yml index 96b775be..868d887c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,9 +13,9 @@ services: dockerfile: ./packages/Dockerfile.chat x-bake: cache-from: - - "ghcr.io/dotabod/twitch-chat:v2.1" + - "ghcr.io/dotabod/cache-twitch-chat:v2.1" cache-to: - - "ghcr.io/dotabod/twitch-chat:v2.1" + - "ghcr.io/dotabod/cache-twitch-chat:v2.1" hostname: twitch-chat environment: - NEW_RELIC_NO_CONFIG_FILE @@ -38,16 +38,16 @@ services: steam: container_name: steam - image: "ghcr.io/dotabod/steam:v2.1" + image: "ghcr.io/dotabod/steam:v2.2" restart: on-failure:5 build: context: . dockerfile: ./packages/Dockerfile.steam x-bake: cache-from: - - "ghcr.io/dotabod/steam:v2.1" + - "ghcr.io/dotabod/cache-steam:v2.2" cache-to: - - "ghcr.io/dotabod/steam:v2.1" + - "ghcr.io/dotabod/cache-steam:v2.2" hostname: steam environment: - NEW_RELIC_NO_CONFIG_FILE @@ -72,9 +72,9 @@ services: dockerfile: ./packages/Dockerfile.events x-bake: cache-from: - - "ghcr.io/dotabod/twitch-events:v2.1" + - "ghcr.io/dotabod/cache-twitch-events:v2.1" cache-to: - - "ghcr.io/dotabod/twitch-events:v2.1" + - "ghcr.io/dotabod/cache-twitch-events:v2.1" hostname: twitch-events environment: - NEW_RELIC_NO_CONFIG_FILE @@ -99,16 +99,17 @@ services: dota: container_name: dota - image: "ghcr.io/dotabod/dota:v2.1" + image: "ghcr.io/dotabod/dota:v2.16" restart: on-failure:5 + # random build: context: . dockerfile: ./packages/Dockerfile.dota x-bake: cache-from: - - "ghcr.io/dotabod/dota:v2.1" + - "ghcr.io/dotabod/cache-dota:v2.16" cache-to: - - "ghcr.io/dotabod/dota:v2.1" + - "ghcr.io/dotabod/cache-dota:v2.16" hostname: dota environment: - D2PT_TOKEN diff --git a/packages/steam/src/index.ts b/packages/steam/src/index.ts index 0a178e0e..d63dbec2 100644 --- a/packages/steam/src/index.ts +++ b/packages/steam/src/index.ts @@ -10,7 +10,7 @@ const io = new Server(5035) const dota = Dota.getInstance() dota.dota2.on('ready', () => { - logger.info('[SERVER] Connected to dota game coordinator') + logger.info('[SERVER] Connected to dota game server') isConnectedToSteam = true })