Skip to content

feat: Support for Management API CLI #23

feat: Support for Management API CLI

feat: Support for Management API CLI #23

Workflow file for this run

name: Build and Deploy to AWS S3
on:
pull_request:
branches:
- master # Trigger on PRs targeting 'master' branch
types:
- open
- synchronize
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
id-token: write # Required for OIDC
contents: read # Required to fetch repo contents
steps:
# Step 1: Checkout the code
- name: Checkout code
uses: actions/checkout@v4
# Step 2: Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
# Step 3: Install dependencies
- name: Install dependencies
run: npm ci --include=dev
# Step 4: Build the project
- name: Build package
run: npm run build
# Step 5: Configure AWS credentials via OIDC
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.AWS_S3_ARN }}
# aws-region: ap-southeast-2
# mask-aws-account-id: true
# # Step 6: Upload to S3
# - name: Upload to S3
# run: |
# aws s3 cp ./dist s3://universal-login-sample-app/ --recursive
- name: Manually create test folders under dist/ (for testing only)
run: |
mkdir -p dist/loginid
mkdir -p dist/login
# Copy the existing built files into these folders
cp dist/index.js dist/loginid/index.js
cp dist/index.css dist/loginid/index.css
cp dist/index.html dist/loginid/index.html
cp dist/*.png dist/loginid/
cp dist/index.js dist/login/index.js
cp dist/index.css dist/login/index.css
cp dist/index.html dist/login/index.html
cp dist/*.png dist/login/
echo "Created test folders with copied build files:"
ls -R dist/
# - name: Generate settings JSON files dynamically
# run: |
# for screen_folder in dist/*; do
# if [ -d "$screen_folder" ]; then
# screen_name=$(basename "$screen_folder")
# cat > "$screen_name-settings.json" << 'EOF'
# {
# "rendering_mode": "advanced",
# "context_configuration": [
# "screen.texts",
# "screen.hasCaptcha",
# "screen.captchaImage"
# ],
# "head_tags": [
# {
# "tag": "script",
# "attributes": {
# "src": "\$CDN_URL/$screen_name/index.js",
# "integrity": "sha384-\$jsHash",
# "crossorigin": "anonymous"
# }
# },
# {
# "tag": "link",
# "attributes": {
# "href": "\$CDN_URL/$screen_name/index.css",
# "rel": "stylesheet",
# "integrity": "sha384-\$cssHash",
# "crossorigin": "anonymous"
# }
# }
# ]
# }
# EOF
# echo "Generated settings file: $screen_name-settings.json"
# fi
# done
- name: Install jq (if not available)
run: sudo apt-get install jq -y
- name: Generate settings JSON files dynamically
run: |
for screen_folder in dist/*; do
if [ -d "$screen_folder" ]; then
screen_name=$(basename "$screen_folder")
jq -n --arg screen_name "$screen_name" \
--arg cdn_url "${{ secrets.CDN_URL }}" \
--arg js_hash "$jsHash" \
--arg css_hash "$cssHash" \
'{
"rendering_mode": "advanced",
"context_configuration": [
"screen.texts",
"screen.hasCaptcha",
"screen.captchaImage"
],
"head_tags": [
{
"tag": "script",
"attributes": {
"src": ($cdn_url + "/" + $screen_name + "/index.js"),
"integrity": ("sha384-" + $js_hash),
"crossorigin": "anonymous"
}
},
{
"tag": "link",
"attributes": {
"href": ($cdn_url + "/" + $screen_name + "/index.css"),
"rel": "stylesheet",
"integrity": ("sha384-" + $css_hash),
"crossorigin": "anonymous"
}
}
]
}' > "$screen_name-settings.json"
echo "Generated settings file: $screen_name-settings.json"
cat "$screen_name-settings.json"
fi
done
- name: Install Auth0 CLI
run: |
# Download and install Auth0 CLI
curl -sSfL https://raw.githubusercontent.com/auth0/auth0-cli/main/install.sh | sh -s -- -b .
# Move it to /usr/local/bin for system-wide access
sudo mv ./auth0 /usr/local/bin/
- name: Authorize with Tenant Details
run: |
auth0 login \
--domain ${{ secrets.AUTH0_DOMAIN }} \
--client-id ${{ secrets.AUTH0_CLIENT_ID }} \
--client-secret ${{ secrets.AUTH0_CLIENT_SECRET }}
auth0 domains list
- name: Update Management API using Auth0 CLI
run: |
for screen_folder in dist/*; do
if [ -d "$screen_folder" ]; then
screen_name=$(basename "$screen_folder")
auth0 ul customize --rendering-mode advanced --prompt login-id --screen $screen_name --settings-file "./$screen_name-settings.json"
echo "Updated Auth0 UI for screen: $screen_name"
fi
done
- name: Logout The Tenant
run: |
auth0 logout \
--domain ${{ secrets.AUTH0_DOMAIN }}