From 6464f32e3665c1de829ae9ce3b8b6af67b28766f Mon Sep 17 00:00:00 2001 From: Eyal Cherevatsky Date: Tue, 8 Oct 2024 10:54:20 +0300 Subject: [PATCH] Use `APP_ID` instead of the non-existing `APP_NAME` (#152) --- README.md | 2 +- utils/env.go | 2 +- utils/env_test.go | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7f45521..5146528 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ The following action deploys the app whenever a new commit is pushed to the main In this case, a secret of the repository named `SOME_SECRET_FROM_REPOSITORY` will also be passed into the app via its environment variables as `SOME_SECRET`. It is passed to the action's environment via the `${{ secrets.KEY }}` notation and then substituted into the spec itself via the environment variable reference in `value`. Make sure to define the respective env var's type as `SECRET` in the spec to ensure the value is stored in an encrypted way. -**Note:** `APP_DOMAIN`, `APP_URL` and `APP_NAME` are predefined [App-wide variables](https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/#app-wide-variables). Avoid overriding them in the action's environment to avoid the env-var-expansion process of the Github Action to interfere with that of the platform itself. +**Note:** `APP_DOMAIN`, `APP_URL` and `APP_ID` are predefined [App-wide variables](https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/#app-wide-variables). Avoid overriding them in the action's environment to avoid the env-var-expansion process of the Github Action to interfere with that of the platform itself. ```yaml name: Update App diff --git a/utils/env.go b/utils/env.go index f97a13d..018918a 100644 --- a/utils/env.go +++ b/utils/env.go @@ -11,7 +11,7 @@ import ( var appWideVariables = map[string]struct{}{ "APP_DOMAIN": {}, "APP_URL": {}, - "APP_NAME": {}, + "APP_ID": {}, } // ExpandEnvRetainingBindables expands the environment variables in s, but it diff --git a/utils/env_test.go b/utils/env_test.go index b1904d6..e138149 100644 --- a/utils/env_test.go +++ b/utils/env_test.go @@ -39,3 +39,30 @@ func TestExpandEnvRetainingBindables(t *testing.T) { }) } } + +func TestExpandEnvRetainingBindablesAppWideVariables(t *testing.T) { + tests := []struct { + name string + in string + out string + }{{ + name: "APP_DOMAIN", + in: "${APP_DOMAIN}", + out: "${APP_DOMAIN}", + }, { + name: "APP_URL", + in: "${APP_URL}", + out: "${APP_URL}", + }, { + name: "APP_ID", + in: "${APP_ID}", + out: "${APP_ID}", + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := ExpandEnvRetainingBindables(test.in) + require.Equal(t, test.out, got) + }) + } +}