Skip to content

Commit

Permalink
update env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Aug 3, 2024
1 parent f3fb5a3 commit 1da0bdc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ dagger call pages-deploy --src . \

## 🛠️ Environment Variables

| Variable | Description |
|---------------|--------------------------------------------------------------|
| CF_API_TOKEN | Your Cloudflare API Token. |
| CF_ACCOUNT_ID | Your Cloudflare Account ID. |
| DIRECTORY | The directory to deploy to Cloudflare Pages. Defaults to `.` |
| PROJECT_NAME | The name of your project. |
| Variable | Description |
|-----------------------|--------------------------------------------------------------|
| CLOUDFLARE_API_TOKEN | Your Cloudflare API Token. |
| CLOUDFLARE_ACCOUNT_ID | Your Cloudflare Account ID. |
| DIRECTORY | The directory to deploy to Cloudflare Pages. Defaults to `.` |
| PROJECT_NAME | The name of your project. |

## ✨ Jobs

Expand Down Expand Up @@ -83,7 +83,7 @@ import { deploy } from "jsr:@fluentci/cloudflare";

await deploy(
".",
Deno.env.get("CF_API_TOKEN")!,
Deno.env.get("CF_ACCOUNT_ID")!
Deno.env.get("CLOUDFLARE_API_TOKEN")!,
Deno.env.get("CLOUDFLARE_ACCOUNT_ID")!
);
```
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fluentci/cloudflare",
"version": "0.8.0",
"version": "0.8.1",
"exports": "./mod.ts",
"importMap": "import_map.json",
"tasks": {
Expand Down Expand Up @@ -31,4 +31,4 @@
"gen/"
]
}
}
}
4 changes: 2 additions & 2 deletions src/dagger/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function deploy(
const context = await getDirectory(src);
const secret = await getApiToken(apiToken);
if (!secret) {
console.error("CF_API_TOKEN environment variable is required");
console.error("CLOUDFLARE_API_TOKEN environment variable is required");
exit(1);
return "";
}
Expand All @@ -50,7 +50,7 @@ export async function deploy(
.withSecretVariable("CLOUDFLARE_API_TOKEN", secret)
.withEnvVariable(
"CLOUDFLARE_ACCOUNT_ID",
env.get("CF_ACCOUNT_ID") || accountId || ""
env.get("CCLOUDFLARE_ACCOUNT_ID") || env.get("CF_ACCOUNT_ID") || accountId || ""
)
.withExec(["bun", "install"])
.withExec(["bunx", `wrangler@${WRANGLER_VERSION}`, "deploy"]);
Expand Down
6 changes: 3 additions & 3 deletions src/dagger/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ export const getDirectory = async (
};

export const getApiToken = async (token?: string | Secret) => {
if (env.get("CF_API_TOKEN")) {
return dag.setSecret("CF_API_TOKEN", env.get("CF_API_TOKEN")!);
if (env.get("CLOUDFLARE_API_TOKEN") || env.get("CF_API_TOKEN")) {
return dag.setSecret("CLOUDFLARE_API_TOKEN", env.get("CLOUDFLARE_API_TOKEN") || env.get("CF_API_TOKEN")!);
}
if (token && typeof token === "string") {
try {
const secret = dag.loadSecretFromID(token as SecretID);
await secret.id();
return secret;
} catch (_) {
return dag.setSecret("CF_API_TOKEN", token);
return dag.setSecret("CLOUDFLARE_API_TOKEN", token);
}
}
if (token && token instanceof Secret) {
Expand Down

0 comments on commit 1da0bdc

Please sign in to comment.