Skip to content

Commit

Permalink
Use APP_ID instead of the non-existing APP_NAME (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalch authored Oct 8, 2024
1 parent eb93ca8 commit 6464f32
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion utils/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions utils/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}

0 comments on commit 6464f32

Please sign in to comment.