Skip to content

Commit

Permalink
chore: add deploy script to ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Orkuncakilkaya committed Oct 31, 2023
1 parent 0eb6110 commit 42f86fd
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 6 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,15 @@ jobs:
AK_ACCESS_TOKEN: '${{secrets.AK_ACCESS_TOKEN}}'
AK_GROUP_ID: '${{secrets.AK_GROUP_ID}}'
AK_CONTRACT_ID: '${{secrets.AK_CONTRACT_ID}}'
run: yarn ts-node scripts/createProperty.ts
run: yarn ts-node scripts/createProperty.ts
- name: Deploy Akamai Rules
id: deploy-rules
env:
BRANCH_NAME: '${{steps.extract-branch.outputs.BRANCH_NAME}}'
AK_HOST: '${{secrets.AK_HOST}}'
AK_CLIENT_TOKEN: '${{secrets.AK_CLIENT_TOKEN}}'
AK_CLIENT_SECRET: '${{secrets.AK_CLIENT_SECRET}}'
AK_ACCESS_TOKEN: '${{secrets.AK_ACCESS_TOKEN}}'
AK_GROUP_ID: '${{secrets.AK_GROUP_ID}}'
AK_CONTRACT_ID: '${{secrets.AK_CONTRACT_ID}}'
run: yarn ts-node scripts/deployRules.ts
17 changes: 12 additions & 5 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ const args = arg({

args['--type'] = args['--type'] ? args['--type'] : 'all'

const patchBody = () => {
export interface PatchBodyArgs {
integrationPath: string,
agentPath: string,
resultPath: string,
proxySecret: string,
}

export const patchBody = (_args?: PatchBodyArgs) => {
const bodyContent = generatePatchBody({
integrationPath: args["--integration-path"],
agentPath: args["--agent-path"],
resultPath: args["--result-path"],
proxySecret: args["--proxy-secret"],
integrationPath: args["--integration-path"] ?? _args?.integrationPath,
agentPath: args["--agent-path"] ?? _args?.agentPath,
resultPath: args["--result-path"] ?? _args?.resultPath,
proxySecret: args["--proxy-secret"] ?? _args?.proxySecret,
})

fs.mkdirSync(path.relative(process.cwd(), 'dist/patch-body'), {recursive: true})
Expand Down
33 changes: 33 additions & 0 deletions scripts/deployRules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {patchBody} from "../build";
import {eg} from "./utils/edgeGrid";

patchBody({
integrationPath: 'worker',
agentPath: 'agent',
resultPath: 'result',
proxySecret: 'abc123',
})

import('../dist/patch-body/body.json').then(module => {

Check failure on line 11 in scripts/deployRules.ts

View workflow job for this annotation

GitHub Actions / ci

Cannot find module '../dist/patch-body/body.json' or its corresponding type declarations.
const content = module.default as object;

eg.auth({
path: `/papi/v1/properties?contractId=${process.env.AK_CONTRACT_ID}&groupId=${process.env.AK_GROUP_ID}`,
method: 'GET',
})

eg.send((err, response, body) => {
const {properties} = JSON.parse(body ?? '{}');
const property = properties.items.find(t => t.propertyName === `${process.env.BRANCH_NAME}.cfi-fingerprint.com`);

eg.auth({
path: `/papi/v1/properties/${property.propertyId}/versions/${property.latestVersion}/rules?contractId=${process.env.AK_CONTRACT_ID}&groupId=${process.env.AK_GROUP_ID}`,
method: 'PATCH',
body: JSON.stringify(content),
});

eg.send((err, response, body) => {
// TODO: Deploy Successful
});
});
})

0 comments on commit 42f86fd

Please sign in to comment.