Skip to content

Commit 503dd3c

Browse files
authored
Fix ab-testing deploy workflows (#14642)
* fix ab-testing deploy workflows * use secrets in deploy env * deploy script needs access to api token * need the build artifact * update test name to check deploy
1 parent 6a0b16c commit 503dd3c

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

.github/workflows/ab-testing-checks.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ permissions:
55

66
on:
77
workflow_call:
8+
inputs:
9+
save_build_artifact:
10+
description: 'Whether to save the built files as an artifact'
11+
required: false
12+
type: boolean
13+
default: false
814
secrets:
915
FASTLY_AB_TESTING_CONFIG:
1016
required: true
@@ -36,3 +42,9 @@ jobs:
3642

3743
- name: Build
3844
run: deno task build
45+
46+
- if: ${{ inputs.save_build_artifact }}
47+
uses: actions/[email protected]
48+
with:
49+
name: ab-testing-build
50+
path: ab-testing/dist

.github/workflows/ab-testing-deploy-code.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,18 @@ on:
99
jobs:
1010
ci:
1111
uses: ./.github/workflows/ab-testing-checks.yml
12+
with:
13+
save_build_artifact: true
1214
secrets:
1315
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_CODE_AB_TESTING_CONFIG }}
1416
FASTLY_API_TOKEN: ${{ secrets.FASTLY_CODE_API_TOKEN }}
1517

1618
deploy:
1719
name: Deploy CODE
1820
needs: ci
19-
runs-on: ubuntu-latest
20-
defaults:
21-
run:
22-
working-directory: ab-testing
23-
steps:
24-
- name: Deploy
25-
uses: ./.github/workflows/ab-testing-deploy.yml
26-
with:
27-
stage: code
28-
env:
29-
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_CODE_AB_TESTING_CONFIG }}
30-
FASTLY_API_TOKEN: ${{ secrets.FASTLY_CODE_API_TOKEN }}
21+
uses: ./.github/workflows/ab-testing-deploy.yml
22+
with:
23+
stage: code
24+
secrets:
25+
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_CODE_AB_TESTING_CONFIG }}
26+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_CODE_API_TOKEN }}

.github/workflows/ab-testing-deploy-prod.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,18 @@ on:
1414
jobs:
1515
ci:
1616
uses: ./.github/workflows/ab-testing-checks.yml
17+
with:
18+
save_build_artifact: true
1719
secrets:
1820
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_PROD_AB_TESTING_CONFIG }}
1921
FASTLY_API_TOKEN: ${{ secrets.FASTLY_PROD_API_TOKEN }}
22+
2023
deploy:
2124
name: Deploy PROD
2225
needs: ci
23-
runs-on: ubuntu-latest
24-
defaults:
25-
run:
26-
working-directory: ab-testing
27-
steps:
28-
- name: Deploy
29-
uses: ./.github/workflows/ab-testing-deploy.yml
30-
with:
31-
stage: prod
32-
env:
33-
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_PROD_AB_TESTING_CONFIG }}
34-
FASTLY_API_TOKEN: ${{ secrets.FASTLY_PROD_API_TOKEN }}
26+
uses: ./.github/workflows/ab-testing-deploy.yml
27+
with:
28+
stage: prod
29+
secrets:
30+
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_PROD_AB_TESTING_CONFIG }}
31+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_PROD_API_TOKEN }}

.github/workflows/ab-testing-deploy.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,14 @@ jobs:
3131
with:
3232
deno-version: v2.3
3333

34+
- name: Download build artifact
35+
uses: actions/[email protected]
36+
with:
37+
name: ab-testing-build
38+
path: ab-testing/dist
39+
3440
- name: Deploy
3541
run: deno run deploy
42+
env:
43+
FASTLY_AB_TESTING_CONFIG: ${{ secrets.FASTLY_AB_TESTING_CONFIG }}
44+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

ab-testing/abTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type { ABTest } from './types';
2222
export const ABTests: ABTest[] = [
2323
// Sample tests that will be used for testing the AB testing framework
2424
{
25-
name: 'commercial-client-side-test',
25+
name: 'commercial-client-side-test-1',
2626
description:
2727
'Show new ad block ask component in ad slots when we detect ad blocker usage',
2828
owners: ['[email protected]'],
@@ -34,7 +34,7 @@ export const ABTests: ABTest[] = [
3434
shouldForceMetricsCollection: true,
3535
},
3636
{
37-
name: 'commercial-server-side-test',
37+
name: 'commercial-server-side-test-1',
3838
description:
3939
'Show new ad block ask component in ad slots when we detect ad blocker usage',
4040
owners: ['[email protected]'],

ab-testing/deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"tasks": {
33
"validate": "deno run scripts/validation/index.ts",
4-
"deploy": "deno run --allow-read=dist --allow-env=FASTLY_AB_TESTING_CONFIG --allow-net=api.fastly.com:443 scripts/deploy/index.ts --mvts=dist/mvts.json --ab-tests=dist/ab-tests.json",
4+
"deploy": "deno run --allow-read=dist --allow-env=FASTLY_AB_TESTING_CONFIG,FASTLY_API_TOKEN --allow-net=api.fastly.com:443 scripts/deploy/index.ts --mvts=dist/mvts.json --ab-tests=dist/ab-tests.json",
55
"build": "deno run --allow-write=dist --allow-env=FASTLY_AB_TESTING_CONFIG,FASTLY_API_TOKEN --allow-net=api.fastly.com:443 scripts/build/index.ts --mvts=dist/mvts.json --ab-tests=dist/ab-tests.json"
66
},
77
"imports": {

0 commit comments

Comments
 (0)