From 8a8235fe8d478dd76a3dd5e13221ce9c24f0a8bc Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 28 Dec 2023 14:20:59 -0500 Subject: [PATCH] Add image manifest fetching and comparison Update image manifest retrieval in builder workflow Update image manifest retrieval in builder workflow Add debugging step to check token presence Update token presence check in builder.yml Add environment variable for production deployment Add test to server export Add debug statement to compare manifests Update manifest comparison for debug purposes Add new images to check_updates job Fix bug in login functionality rm Fix image name replacement in builder workflow check tag instead, we'll just push newn versions Update Dota image version to v2.16 Remove unnecessary steps and actions from builder workflow test revert deployer try a pat try a test try it all outputting test try try test try try test Add deploy check and package mapping to UUID t try t f Update workflow to release to Coolify test c Update builder and deploy workflows Remove unnecessary options from docker/bake-action Update builder.yml to disable OCI mediatypes for Docker output try 2 Refactor build and push step to use docker compose Update build and push action in builder.yml Update builder.yml to set output-type to docker rebuild Update Docker build configuration Add no-cache option to docker bake action test Update Docker Buildx and disable sbom and provenance try test Add docker compose pull command Update Docker cache image names Add debug output for event json Remove test commit Update logger message in index.ts Remove sbom flag from docker/bake-action Add no-cache option to builder workflow Remove no-cache option and update console log message Update builder.yml to set platform to linux/arm64 Refactor deploy workflow to remove debug output and check for recent buildkit/createdat timestamps Refactor console log message in steam index.ts Add deployment workflow for prod and dev environments Refactor release workflow to notify Coolify for both Prod and Dev environments --- .github/workflows/builder.yml | 6 +++-- .github/workflows/deploy.yml | 51 ++++++++++++++++++++--------------- docker-compose.yml | 21 ++++++++------- packages/steam/src/index.ts | 2 +- 4 files changed, 45 insertions(+), 35 deletions(-) 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 })