Skip to content

Commit 19ce30b

Browse files
[CJS-8078] update example workflow (#2)
* update example workflow * update example workflow
1 parent 3cd94e3 commit 19ce30b

File tree

2 files changed

+49
-9
lines changed

2 files changed

+49
-9
lines changed

examples/manual.yml

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@ on:
77
description: 'Path from root directory to file with custom code'
88
required: true
99
custom-code-level:
10-
description: 'project, experiment, or variation'
11-
required: false
10+
description: 'Select the level of custom code upload'
11+
required: true
12+
type: choice
13+
options:
14+
- project
15+
- experiment
16+
- variation
1217
default: 'variation'
1318
custom-code-type:
14-
description: 'custom_code or custom_css'
15-
required: false
19+
description: 'Select the type of custom code (Custom JS or Custom CSS)'
20+
required: true
21+
type: choice
22+
options:
23+
- custom_code
24+
- custom_css
1625
default: 'custom_code'
1726
project-id:
1827
description: 'Project ID - required for Project Level Changes'
@@ -28,23 +37,54 @@ on:
2837
required: false
2938
no-comment:
3039
description: 'No Comment - Whether or not a comment SHOULD NOT be appended to the end of the custom code'
31-
required: false
40+
required: true
41+
type: choice
42+
options:
43+
- true
44+
- false
3245
default: 'false'
3346
custom-comment:
3447
description: 'Custom Comment - A comment to be appended to the end of the custom code'
3548
required: false
3649
default: 'This code was uploaded via the Optimizely Upload Custom Code Github Action.'
3750
fail-silently:
3851
description: 'Fail Silently - When set to true, only print errors in logs but does not fail entire workflow'
39-
required: false
52+
required: true
53+
type: choice
54+
options:
55+
- true
56+
- false
4057
default: 'false'
58+
4159
jobs:
60+
validate_inputs:
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Validate required fields
64+
run: |
65+
if [ "${{ github.event.inputs.custom-code-level }}" = "project" ] && [ -z "${{ github.event.inputs.project-id }}" ]; then
66+
echo "Error: 'project-id' is required for custom-code-level 'project'."
67+
exit 1
68+
fi
69+
if [ "${{ github.event.inputs.custom-code-level }}" = "experiment" ] && [ -z "${{ github.event.inputs.experiment-id }}" ]; then
70+
echo "Error: 'experiment-id' is required for custom-code-level 'experiment'."
71+
exit 1
72+
fi
73+
if [ "${{ github.event.inputs.custom-code-level }}" = "variation" ] && [ -z "${{ github.event.inputs.variation-id }}" ]; then
74+
echo "Error: 'variation-id' is required for custom-code-level 'variation'."
75+
exit 1
76+
fi
77+
4278
update_experiment_custom_code:
4379
runs-on: ubuntu-latest
4480
name: A job to upload custom code to an Optimizely experiment
81+
needs: validate_inputs
4582
steps:
83+
- name: My first step - check out repository
84+
uses: actions/checkout@v4
85+
4686
- name: Upload custom code
47-
uses: optimizely/upload-custom-code-action@1.0.0
87+
uses: optimizely/upload-custom-code-action@v1.0.3
4888
id: upload-custom-code
4989
with:
5090
optimizely-access-token: ${{ secrets.OPTIMIZELY_API_ACCESS_TOKEN }}
@@ -60,4 +100,4 @@ jobs:
60100
fail-silently: ${{ github.event.inputs.fail-silently }}
61101
# Use the output from the `upload custom code` step
62102
- name: Get the upload result
63-
run: echo "Was the process was successful? ${{ steps.upload-custom-code.outputs.success }}"
103+
run: echo "Was the process successful? ${{ steps.upload-custom-code.outputs.success }}"

examples/on-issue-comment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
1919
- name: Upload custom code
2020
if: ${{ steps.checkForKeyword.outputs.triggered == 'true' }}
21-
uses: optimizely/upload-custom-code-action@1.0.0
21+
uses: optimizely/upload-custom-code-action@v1.0.3
2222
id: upload-custom-code
2323
with:
2424
optimizely-access-token: ${{ secrets.OPTIMIZELY_API_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)