From 013eb0953f864c3336232bc7458e3646eddc22ca Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Fri, 12 Jul 2024 14:53:21 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=B3=20trying=20depot=20build=20(#927)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build * 🐳 trying depot build --- .github/workflows/publish-checker.yml | 37 +++++++++++++++++++++++++++ apps/checker/README.md | 2 ++ apps/checker/cmd/main.go | 28 ++++++++++++-------- 3 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/publish-checker.yml diff --git a/.github/workflows/publish-checker.yml b/.github/workflows/publish-checker.yml new file mode 100644 index 0000000000..2510f08786 --- /dev/null +++ b/.github/workflows/publish-checker.yml @@ -0,0 +1,37 @@ +name: Publish Checker +on: + push: + branches: + - main + paths: + - "apps/checker/**" +env: + REGISTRY: ghcr.io + IMAGE_NAME: checker + +jobs: + build: + runs-on: ubuntu-latest + # Permissions to use OIDC token authentication + permissions: + contents: read + id-token: write + # Allows pushing to the GitHub Container Registry + packages: write + steps: + - uses: actions/checkout@v3 + - uses: depot/setup-action@v1 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: depot/build-push-action@v1 + with: + project: 9cknw183m8 + context: apps/checker + tags: ghcr.io/openstatushq/checker:latest + push: true + diff --git a/apps/checker/README.md b/apps/checker/README.md index 135f8a8f39..699665222f 100644 --- a/apps/checker/README.md +++ b/apps/checker/README.md @@ -34,3 +34,5 @@ fly deploy ```bash fly scale count 35 --region ams,arn,atl,bog,bom,bos,cdg,den,dfw,ewr,eze,fra,gdl,gig,gru,hkg,iad,jnb,lax,lhr,mad,mia,nrt,ord,otp,phx,qro,scl,sjc,sea,sin,syd,waw,yul,yyz ``` + +## Build diff --git a/apps/checker/cmd/main.go b/apps/checker/cmd/main.go index a5750deb13..e7ccb9eba2 100644 --- a/apps/checker/cmd/main.go +++ b/apps/checker/cmd/main.go @@ -54,10 +54,11 @@ func main() { }() // environment variables. - flyRegion := env("FLY_REGION", "local") + flyRegion := env("FLY_REGION", env("REGION", "local")) cronSecret := env("CRON_SECRET", "") tinyBirdToken := env("TINYBIRD_TOKEN", "") logLevel := env("LOG_LEVEL", "warn") + cloudProvider := env("CLOUD_PROVIDER", "fly") logger.Configure(logLevel) @@ -79,12 +80,14 @@ func main() { return } - // if the request has been routed to a wrong region, we forward it to the correct one. - region := c.GetHeader("fly-prefer-region") - if region != "" && region != flyRegion { - c.Header("fly-replay", fmt.Sprintf("region=%s", region)) - c.String(http.StatusAccepted, "Forwarding request to %s", region) - return + if cloudProvider == "fly" { + // if the request has been routed to a wrong region, we forward it to the correct one. + region := c.GetHeader("fly-prefer-region") + if region != "" && region != flyRegion { + c.Header("fly-replay", fmt.Sprintf("region=%s", region)) + c.String(http.StatusAccepted, "Forwarding request to %s", region) + return + } } var req request.CheckerRequest @@ -275,10 +278,13 @@ func main() { return } - if region != flyRegion { - c.Header("fly-replay", fmt.Sprintf("region=%s", region)) - c.String(http.StatusAccepted, "Forwarding request to %s", region) - return + if cloudProvider == "fly" { + + if region != flyRegion { + c.Header("fly-replay", fmt.Sprintf("region=%s", region)) + c.String(http.StatusAccepted, "Forwarding request to %s", region) + return + } } // We need a new client for each request to avoid connection reuse. requestClient := &http.Client{