Skip to content

Commit

Permalink
BC-5468 update main.yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
UzaeirKhan committed Nov 5, 2023
1 parent 0c985a1 commit 4ce0673
Showing 1 changed file with 75 additions and 45 deletions.
120 changes: 75 additions & 45 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ on:
jobs:
configure-load-secrets-and-run_tests:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.setting_url.outputs.TAG }}
# outputs:
# tag: ${{ steps.setting_url.outputs.TAG }}

steps:
- name: Checkout
Expand All @@ -33,52 +33,81 @@ jobs:
with:
service-account-token: ${{ secrets.service-account-token }}

- name: Setting URL's
id: setting_url
# - name: Setting URL's
# id: setting_url
# run: |
# workflow_name="${{ github.workflow }}"
# if [[ $workflow_name == *"manual"* ]]; then
# echo "This is a manual workflow"
# echo "CYPRESS_BRB=${{ github.event.inputs.instance1 }}" >> $GITHUB_ENV
# echo "$CYPRESS_BRB"
# echo "CYPRESS_NBC=${{ github.event.inputs.instance2 }}" >> $GITHUB_ENV
# echo "$CYPRESS_NBC"
# echo "CYPRESS_DEFAULT=${{ github.event.inputs.instance3 }}" >> $GITHUB_ENV
# echo "$CYPRESS_DEFAULT"
# echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# elif [[ $workflow_name == *"automatic"* || $workflow_name == *"scheduled"* ]]; then
# echo "This is an automatic or scheduled workflow"
# echo "CYPRESS_BRB=op://cy-dev-brb/cypress/CYPRESS_BRB" >> $GITHUB_ENV
# echo "$CYPRESS_BRB"
# echo "CYPRESS_NBC=op://cy-dev-nbc/cypress/CYPRESS_NBC" >> $GITHUB_ENV
# echo "$CYPRESS_NBC"
# echo "CYPRESS_DEFAULT=op://cy-dev-dbc/cypress/CYPRESS_DEFAULT" >> $GITHUB_ENV
# echo "$CYPRESS_DEFAULT"
# echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# else
# echo "This is an remote workflow"
# echo "CYPRESS_BRB=${{ inputs.cypress_brb }}" >> $GITHUB_ENV
# echo "$CYPRESS_BRB"
# echo "CYPRESS_NBC=${{ inputs.cypress_nbc }}" >> $GITHUB_ENV
# echo "$CYPRESS_NBC"
# echo "CYPRESS_DEFAULT=${{ inputs.cypress_default }}" >> $GITHUB_ENV
# echo "$CYPRESS_DEFAULT"
# echo "TAG=tag:stable:pr:ci" >> $GITHUB_OUTPUT
# echo "$TAG"
# fi

# - name: Set Environment Variables
# run: |
# chmod +x ${{ github.workspace }}/e2e-system-tests/scripts/set-env-vars.sh
# ${{ github.workspace }}/e2e-system-tests/scripts/set-env-vars.sh

- name: Fetch JSON files from 1Password
run: |
workflow_name="${{ github.workflow }}"
if [[ $workflow_name == *"manual"* ]]; then
echo "This is a manual workflow"
echo "CYPRESS_BRB=${{ github.event.inputs.instance1 }}" >> $GITHUB_ENV
echo "$CYPRESS_BRB"
echo "CYPRESS_NBC=${{ github.event.inputs.instance2 }}" >> $GITHUB_ENV
echo "$CYPRESS_NBC"
echo "CYPRESS_DEFAULT=${{ github.event.inputs.instance3 }}" >> $GITHUB_ENV
echo "$CYPRESS_DEFAULT"
echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
echo "$TAG"
elif [[ $workflow_name == *"automatic"* || $workflow_name == *"scheduled"* ]]; then
echo "This is an automatic or scheduled workflow"
echo "CYPRESS_BRB=op://cy-dev-brb/cypress/CYPRESS_BRB" >> $GITHUB_ENV
echo "$CYPRESS_BRB"
echo "CYPRESS_NBC=op://cy-dev-nbc/cypress/CYPRESS_NBC" >> $GITHUB_ENV
echo "$CYPRESS_NBC"
echo "CYPRESS_DEFAULT=op://cy-dev-dbc/cypress/CYPRESS_DEFAULT" >> $GITHUB_ENV
echo "$CYPRESS_DEFAULT"
echo "TAG=tag:stable:ci" >> $GITHUB_OUTPUT
echo "$TAG"
else
echo "This is an remote workflow"
echo "CYPRESS_BRB=${{ inputs.cypress_brb }}" >> $GITHUB_ENV
echo "$CYPRESS_BRB"
echo "CYPRESS_NBC=${{ inputs.cypress_nbc }}" >> $GITHUB_ENV
echo "$CYPRESS_NBC"
echo "CYPRESS_DEFAULT=${{ inputs.cypress_default }}" >> $GITHUB_ENV
echo "$CYPRESS_DEFAULT"
echo "TAG=tag:stable:pr:ci" >> $GITHUB_OUTPUT
echo "$TAG"
fi
instances=(brb dbc nbc)
environments=(dev ref)
for instance in "${instances[@]}"; do
for environment in "${environments[@]}"; do
vault_name="cy-${environment}-${instance}"
op get document test --vault "$vault_name" --output ${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json
done
done
- name: Set Environment Variables
- name: Read JSON files and set environment variables
run: |
chmod +x ${{ github.workspace }}/e2e-system-tests/scripts/set-env-vars.sh
${{ github.workspace }}/e2e-system-tests/scripts/set-env-vars.sh
instances=(brb dbc nbc)
environments=(dev ref)
- name: Load secret
id: op-load-secret
uses: 1password/load-secrets-action@v1
with:
export-env: true
for instance in "${instances[@]}"; do
for environment in "${environments[@]}"; do
file_path="${{ github.workspace }}/e2e-system-tests/env_variables/file-${environment}-${instance}.json"
while IFS="=" read -r key value; do
# if [[ ! "$key" =~ ^CYPRESS_(BRB|NBC|DEFAULT)_ ]]; then
echo "Setting $key"
echo "$key=$value" >> $GITHUB_ENV
# fi
done < <(jq -r 'to_entries | .[] | .key + "=" + .value' "$file_path")
done
done
# - name: Load secret
# id: op-load-secret
# uses: 1password/load-secrets-action@v1
# with:
# export-env: true

- name: Clean up previous report
uses: cypress-io/github-action@v5
Expand All @@ -90,7 +119,8 @@ jobs:
uses: cypress-io/github-action@v5
with:
working-directory: e2e-system-tests
command: npm run ${{ steps.setting_url.outputs.tag }}
# command: npm run ${{ steps.setting_url.outputs.tag }}
command: npm run tag:stable:ci
browser: chrome
env:
DEBUG: "@cypress/github-action"
Expand Down

0 comments on commit 4ce0673

Please sign in to comment.