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'
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+
4159jobs :
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 }}
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 }}"
0 commit comments