Skip to content

Commit

Permalink
test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
unandyala committed Sep 3, 2024
1 parent 4cb56e0 commit 6ddba56
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ jobs:
run: |
set -e
echo "PROJECT_SLUG=scaffold-pwa" >> $GITHUB_ENV
echo "Branch name is: ${{ github.ref_name }}"
branch_name="${GITHUB_REF##*/}"
# Trim using cut as MRT target name is limited to 19 chars
mrt_target_name=$(echo "$branch_name" | cut -c 1-19)
echo "Trimmed branch name: $mrt_target_name"
echo "MRT_TARGET_NAME=$mrt_target_name" >> $GITHUB_ENV
- name: Checkout
Expand Down Expand Up @@ -56,3 +54,28 @@ jobs:
CWD: "packages/template-retail-react-app"
TARGET: ${{ env.MRT_TARGET_NAME }}
FLAGS: --wait

- name: Read application config
id: read_config
run: |
config=$(node -e "console.log(JSON.stringify(require('./config/default.js')))")
echo "proxy_configs=$(echo $config | jq -r '.ssrParameters.proxyConfigs')" >> $GITHUB_OUTPUT
- name: Add proxy config on MRT
shell: bash
run: |
set -e
response=$(curl --location --silent --show-error --write-out "HTTPSTATUS:%{http_code}" --request PATCH "https://cloud.mobify.com/api/projects/${{ github.event.inputs.project_name }}/target/${{ github.event.inputs.mrt_target_env }}/" \
--header "Authorization: Bearer ${{ secrets.MOBIFY_CLIENT_API_KEY }}" \
--header "Content-Type: application/json" \
--data '${{ steps.read_config.outputs.proxy_configs }}')
http_status=$(echo "$response" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
response_body=$(echo "$response" | sed -e 's/HTTPSTATUS\:.*//g')
if [ "$http_status" -ne 200 ]; then
echo "Request failed with status code $http_status"
echo "Response body: $response_body"
exit 1
else
echo "Proxy configuration added successfully."
fi

0 comments on commit 6ddba56

Please sign in to comment.