Skip to content

Commit

Permalink
ci: add logdrain deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
chronark committed Nov 29, 2024
1 parent e8cbdb0 commit c565f0a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 43 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/job_deploy_logdrain_production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Deploy Logdrain Production
on:
workflow_call:
secrets:
CLOUDFLARE_API_TOKEN:
required: true



jobs:
deploy:
environment: Production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install
with:
ts: true

- name: Build
run: pnpm turbo run build --filter='./apps/logdrain'

- name: Deploy
run: wrangler deploy
working-directory: apps/logdrain
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
10 changes: 4 additions & 6 deletions apps/api/src/routes/v1_keys_updateKey.happy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,6 @@ describe("When refillDay is omitted.", () => {
});
});


describe("update name", () => {
test("should not affect ratelimit config", async (t) => {
const h = await IntegrationHarness.init(t);
Expand All @@ -1082,8 +1081,8 @@ describe("update name", () => {
ratelimit: {
async: true,
limit: 10,
duration: 1000
}
duration: 1000,
},
},
});

Expand Down Expand Up @@ -1127,6 +1126,5 @@ describe("update name", () => {
expect(verify.body.ratelimit).toBeDefined();
expect(verify.body.ratelimit!.limit).toBe(10);
expect(verify.body.ratelimit!.remaining).toBe(9);

})
})
});
});
70 changes: 33 additions & 37 deletions apps/api/src/routes/v1_keys_updateKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,74 +340,70 @@ export const registerV1KeysUpdate = (app: App) =>
const authorizedWorkspaceId = auth.authorizedWorkspaceId;
const rootKeyId = auth.key.id;




const changes: Partial<Key> = {}
const changes: Partial<Key> = {};
if (typeof req.name !== "undefined") {
changes.name = req.name
changes.name = req.name;
}
if (typeof req.meta !== "undefined") {
changes.meta = req.meta === null ? null : JSON.stringify(req.meta)
changes.meta = req.meta === null ? null : JSON.stringify(req.meta);
}
if (typeof req.externalId !== "undefined") {
if (req.externalId === null) {
changes.identityId = null
changes.ownerId = null
changes.identityId = null;
changes.ownerId = null;
} else {
const identity = await upsertIdentity(db.primary, authorizedWorkspaceId, req.externalId)
changes.identityId = identity.id
changes.ownerId = req.externalId
const identity = await upsertIdentity(db.primary, authorizedWorkspaceId, req.externalId);
changes.identityId = identity.id;
changes.ownerId = req.externalId;
}
} else if (typeof req.ownerId !== "undefined") {
if (req.ownerId === null) {
changes.identityId = null
changes.ownerId = null
changes.identityId = null;
changes.ownerId = null;
} else {
const identity = await upsertIdentity(db.primary, authorizedWorkspaceId, req.ownerId)
changes.identityId = identity.id
changes.ownerId = req.ownerId
const identity = await upsertIdentity(db.primary, authorizedWorkspaceId, req.ownerId);
changes.identityId = identity.id;
changes.ownerId = req.ownerId;
}
}
if (typeof req.expires !== "undefined") {
changes.expires = req.expires === null ? null : new Date(req.expires)
changes.expires = req.expires === null ? null : new Date(req.expires);
}
if (typeof req.remaining !== "undefined") {
changes.remaining = req.remaining
changes.remaining = req.remaining;
}
if (typeof req.ratelimit !== "undefined") {
if (req.ratelimit === null) {
changes.ratelimitAsync = null
changes.ratelimitLimit = null
changes.ratelimitDuration = null
changes.ratelimitAsync = null;
changes.ratelimitLimit = null;
changes.ratelimitDuration = null;
} else {
changes.ratelimitAsync = typeof req.ratelimit.async === "boolean" ? req.ratelimit.async : req.ratelimit.type === "fast"
changes.ratelimitLimit = req.ratelimit.limit ?? req.ratelimit.refillRate
changes.ratelimitDuration = req.ratelimit.duration ?? req.ratelimit.refillInterval
changes.ratelimitAsync =
typeof req.ratelimit.async === "boolean"
? req.ratelimit.async
: req.ratelimit.type === "fast";
changes.ratelimitLimit = req.ratelimit.limit ?? req.ratelimit.refillRate;
changes.ratelimitDuration = req.ratelimit.duration ?? req.ratelimit.refillInterval;
}

}

if (typeof req.refill !== "undefined") {
if (req.refill === null) {
changes.refillInterval = null
changes.refillAmount = null
changes.refillDay = null
changes.lastRefillAt = null
changes.refillInterval = null;
changes.refillAmount = null;
changes.refillDay = null;
changes.lastRefillAt = null;
} else {
changes.refillInterval = req.refill.interval
changes.refillAmount = req.refill.amount
changes.refillDay = req.refill.refillDay ?? 1
changes.refillInterval = req.refill.interval;
changes.refillAmount = req.refill.amount;
changes.refillDay = req.refill.refillDay ?? 1;
}
}
if (typeof req.enabled !== "undefined") {
changes.enabled = req.enabled
changes.enabled = req.enabled;
}
if (Object.keys(changes).length > 0) {
await db.primary
.update(schema.keys)
.set(changes)
.where(eq(schema.keys.id, key.id));
await db.primary.update(schema.keys).set(changes).where(eq(schema.keys.id, key.id));
}
await insertUnkeyAuditLog(c, undefined, {
workspaceId: authorizedWorkspaceId,
Expand Down

0 comments on commit c565f0a

Please sign in to comment.