Skip to content

[CJS-8078] update example workflow #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions examples/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@ on:
description: 'Path from root directory to file with custom code'
required: true
custom-code-level:
description: 'project, experiment, or variation'
required: false
description: 'Select the level of custom code upload'
required: true
type: choice
options:
- project
- experiment
- variation
default: 'variation'
custom-code-type:
description: 'custom_code or custom_css'
required: false
description: 'Select the type of custom code (Custom JS or Custom CSS)'
required: true
type: choice
options:
- custom_code
- custom_css
default: 'custom_code'
project-id:
description: 'Project ID - required for Project Level Changes'
Expand All @@ -28,23 +37,54 @@ on:
required: false
no-comment:
description: 'No Comment - Whether or not a comment SHOULD NOT be appended to the end of the custom code'
required: false
required: true
type: choice
options:
- true
- false
default: 'false'
custom-comment:
description: 'Custom Comment - A comment to be appended to the end of the custom code'
required: false
default: 'This code was uploaded via the Optimizely Upload Custom Code Github Action.'
fail-silently:
description: 'Fail Silently - When set to true, only print errors in logs but does not fail entire workflow'
required: false
required: true
type: choice
options:
- true
- false
default: 'false'

jobs:
validate_inputs:
runs-on: ubuntu-latest
steps:
- name: Validate required fields
run: |
if [ "${{ github.event.inputs.custom-code-level }}" = "project" ] && [ -z "${{ github.event.inputs.project-id }}" ]; then
echo "Error: 'project-id' is required for custom-code-level 'project'."
exit 1
fi
if [ "${{ github.event.inputs.custom-code-level }}" = "experiment" ] && [ -z "${{ github.event.inputs.experiment-id }}" ]; then
echo "Error: 'experiment-id' is required for custom-code-level 'experiment'."
exit 1
fi
if [ "${{ github.event.inputs.custom-code-level }}" = "variation" ] && [ -z "${{ github.event.inputs.variation-id }}" ]; then
echo "Error: 'variation-id' is required for custom-code-level 'variation'."
exit 1
fi

update_experiment_custom_code:
runs-on: ubuntu-latest
name: A job to upload custom code to an Optimizely experiment
needs: validate_inputs
steps:
- name: My first step - check out repository
uses: actions/checkout@v4

- name: Upload custom code
uses: optimizely/upload-custom-code-action@1.0.0
uses: optimizely/upload-custom-code-action@v1.0.3
id: upload-custom-code
with:
optimizely-access-token: ${{ secrets.OPTIMIZELY_API_ACCESS_TOKEN }}
Expand All @@ -60,4 +100,4 @@ jobs:
fail-silently: ${{ github.event.inputs.fail-silently }}
# Use the output from the `upload custom code` step
- name: Get the upload result
run: echo "Was the process was successful? ${{ steps.upload-custom-code.outputs.success }}"
run: echo "Was the process successful? ${{ steps.upload-custom-code.outputs.success }}"
2 changes: 1 addition & 1 deletion examples/on-issue-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Upload custom code
if: ${{ steps.checkForKeyword.outputs.triggered == 'true' }}
uses: optimizely/upload-custom-code-action@1.0.0
uses: optimizely/upload-custom-code-action@v1.0.3
id: upload-custom-code
with:
optimizely-access-token: ${{ secrets.OPTIMIZELY_API_ACCESS_TOKEN }}
Expand Down
Loading