7
7
description : ' Path from root directory to file with custom code'
8
8
required : true
9
9
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
12
17
default : ' variation'
13
18
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
16
25
default : ' custom_code'
17
26
project-id :
18
27
description : ' Project ID - required for Project Level Changes'
28
37
required : false
29
38
no-comment :
30
39
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
32
45
default : ' false'
33
46
custom-comment :
34
47
description : ' Custom Comment - A comment to be appended to the end of the custom code'
35
48
required : false
36
49
default : ' This code was uploaded via the Optimizely Upload Custom Code Github Action.'
37
50
fail-silently :
38
51
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
40
57
default : ' false'
58
+
41
59
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
+
42
78
update_experiment_custom_code :
43
79
runs-on : ubuntu-latest
44
80
name : A job to upload custom code to an Optimizely experiment
81
+ needs : validate_inputs
45
82
steps :
83
+ - name : My first step - check out repository
84
+ uses : actions/checkout@v4
85
+
46
86
- name : Upload custom code
47
- uses : optimizely/upload-custom-code-action@1 .0.0
87
+ uses : optimizely/upload-custom-code-action@v1 .0.3
48
88
id : upload-custom-code
49
89
with :
50
90
optimizely-access-token : ${{ secrets.OPTIMIZELY_API_ACCESS_TOKEN }}
60
100
fail-silently : ${{ github.event.inputs.fail-silently }}
61
101
# Use the output from the `upload custom code` step
62
102
- 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 }}"
0 commit comments