2025-08-14 10:28:40 +02:00
|
|
|
name: createapp
|
|
|
|
|
|
|
|
|
|
on:
|
|
|
|
|
workflow_dispatch:
|
2025-08-14 11:25:00 +02:00
|
|
|
inputs:
|
2025-08-14 13:15:26 +02:00
|
|
|
a_app_region:
|
2025-08-14 11:25:00 +02:00
|
|
|
type: string
|
|
|
|
|
description: "Application Region e.g. EU"
|
|
|
|
|
default: EU
|
2025-08-27 07:33:45 +00:00
|
|
|
required: true
|
2025-08-14 13:15:26 +02:00
|
|
|
b_app_flavor:
|
2025-08-14 11:25:00 +02:00
|
|
|
type: string
|
|
|
|
|
description: "Application Flavor e.g. EU.small"
|
|
|
|
|
default: EU.small
|
2025-08-27 07:33:45 +00:00
|
|
|
required: true
|
|
|
|
|
c_cloudlet:
|
|
|
|
|
type: choice
|
|
|
|
|
options:
|
|
|
|
|
- Amsterdam-OTC
|
|
|
|
|
- Hamburg
|
|
|
|
|
- Leipzig
|
|
|
|
|
- Munich
|
|
|
|
|
- Berlin
|
|
|
|
|
- Frankfurt
|
|
|
|
|
- Magdeburg-OTC
|
|
|
|
|
- Bonn
|
|
|
|
|
- Magdeburg
|
2025-08-29 09:09:36 +00:00
|
|
|
- crm-vm-2
|
2025-08-27 07:35:26 +00:00
|
|
|
description: "Cloudlet location"
|
2025-08-27 07:33:45 +00:00
|
|
|
default: Munich
|
|
|
|
|
required: true
|
2025-08-14 10:28:40 +02:00
|
|
|
|
|
|
|
|
env:
|
2025-08-29 09:25:36 +00:00
|
|
|
EDGEXR_PLATFORM_USERNAME: ${{ secrets.EDGEXR_PLATFORM_USERNAME }}
|
|
|
|
|
EDGEXR_PLATFORM_PASSWORD: ${{ secrets.EDGEXR_PLATFORM_PASSWORD }}
|
2025-08-14 13:15:26 +02:00
|
|
|
APP_REGION: ${{ inputs.a_app_region }}
|
|
|
|
|
APP_FLAVOR: ${{ inputs.b_app_flavor }}
|
2025-08-27 07:33:45 +00:00
|
|
|
CLOUDLET: ${{ inputs.c_cloudlet }}
|
2025-08-14 10:28:40 +02:00
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
|
build:
|
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
|
|
|
|
|
|
steps:
|
|
|
|
|
-
|
|
|
|
|
name: Repository meta
|
|
|
|
|
id: repository
|
|
|
|
|
run: |
|
|
|
|
|
registry=${{ github.server_url }}
|
|
|
|
|
registry=${registry##http*://}
|
|
|
|
|
echo "registry=${registry}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
echo "registry=${registry}"
|
|
|
|
|
repository="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
|
|
|
|
|
echo "repository=${repository}" >> "$GITHUB_OUTPUT"
|
|
|
|
|
echo "repository=${repository}"
|
|
|
|
|
-
|
|
|
|
|
name: Docker meta
|
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
|
id: docker
|
|
|
|
|
with:
|
|
|
|
|
images: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }}
|
|
|
|
|
-
|
2025-08-21 12:30:29 +00:00
|
|
|
name: Install Dependencies
|
2025-08-14 10:28:40 +02:00
|
|
|
run: |
|
|
|
|
|
sudo apt update
|
|
|
|
|
sudo apt install -y curl jq
|
|
|
|
|
-
|
2025-08-21 12:30:29 +00:00
|
|
|
name: Create Edge Connect App
|
2025-08-14 10:28:40 +02:00
|
|
|
run: |
|
2025-08-14 10:49:11 +02:00
|
|
|
set -e
|
|
|
|
|
echo login
|
2025-09-15 15:24:19 +00:00
|
|
|
EDGEXR_TOKEN="$(curl -X POST https://hub.apps.edge.platform.mg3.mdb.osc.live/api/v1/login -H 'Content-Type: application/json' --data '{"password": "'${EDGEXR_PLATFORM_PASSWORD}'","username": "'${EDGEXR_PLATFORM_USERNAME}'"}' -sSf | jq -r .token)"
|
2025-08-14 10:43:16 +02:00
|
|
|
|
|
|
|
|
CREATEAPP_JSON=$(cat <<EOF
|
|
|
|
|
{
|
2025-08-20 13:00:34 +00:00
|
|
|
"region": "${APP_REGION}",
|
|
|
|
|
"app": {
|
2025-08-14 10:43:16 +02:00
|
|
|
"key": {
|
2025-08-29 09:23:31 +00:00
|
|
|
"organization": "dev-framework",
|
2025-08-14 11:55:31 +02:00
|
|
|
"name": "$(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')",
|
2025-08-14 13:48:55 +02:00
|
|
|
"version": "${{ steps.docker.outputs.version }}"
|
2025-08-14 10:43:16 +02:00
|
|
|
},
|
2025-08-20 13:00:34 +00:00
|
|
|
"deployment": "kubernetes",
|
2025-08-14 10:43:16 +02:00
|
|
|
"image_type": "Docker",
|
2025-08-20 13:00:34 +00:00
|
|
|
"image_path": "${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }}:${{ steps.docker.outputs.version }}",
|
|
|
|
|
"allow_serverless": true,
|
|
|
|
|
"defaultFlavor": {
|
2025-08-14 11:25:00 +02:00
|
|
|
"name": "${APP_FLAVOR}"
|
2025-08-14 10:43:16 +02:00
|
|
|
},
|
2025-08-20 13:00:34 +00:00
|
|
|
"serverless_config": {},
|
|
|
|
|
"deployment_generator": "kubernetes-basic",
|
2025-08-20 13:08:08 +00:00
|
|
|
"deployment_manifest": "apiVersion: v1\nkind: Service\nmetadata:\n name: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')-tcp\n labels:\n run: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')\nspec:\n type: LoadBalancer\n ports:\n - name: tcp80\n protocol: TCP\n port: 80\n targetPort: 80\n selector:\n run: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')\n---\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')-deployment\nspec:\n replicas: 1\n selector:\n matchLabels:\n run: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')\n template:\n metadata:\n labels:\n run: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')\n mexDeployGen: kubernetes-basic\n spec:\n volumes:\n containers:\n - name: $(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')\n image: ${{ steps.repository.outputs.registry }}/${{ steps.repository.outputs.repository }}:${{ steps.docker.outputs.version }}\n imagePullPolicy: Always\n ports:\n - containerPort: 80\n protocol: TCP\n\n"
|
2025-08-20 13:00:34 +00:00
|
|
|
}
|
2025-08-14 10:43:16 +02:00
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
|
2025-08-14 13:44:50 +02:00
|
|
|
echo $CREATEAPP_JSON
|
|
|
|
|
|
2025-08-14 10:49:11 +02:00
|
|
|
echo create app
|
2025-09-15 15:24:19 +00:00
|
|
|
curl -X POST https://hub.apps.edge.platform.mg3.mdb.osc.live/api/v1/auth/ctrl/CreateApp -H 'Content-Type: application/json' -H "Authorization: Bearer $EDGEXR_TOKEN" -S --data "$CREATEAPP_JSON" --fail-with-body
|
2025-08-27 07:33:45 +00:00
|
|
|
-
|
|
|
|
|
name: Create Edge Connect App Instance
|
|
|
|
|
run: |
|
|
|
|
|
set -e
|
2025-09-15 15:24:19 +00:00
|
|
|
EDGEXR_TOKEN="$(curl -X POST https://hub.apps.edge.platform.mg3.mdb.osc.live/api/v1/login -H 'Content-Type: application/json' --data '{"password": "'${EDGEXR_PLATFORM_PASSWORD}'","username": "'${EDGEXR_PLATFORM_USERNAME}'"}' -sSf | jq -r .token)"
|
2025-08-27 07:33:45 +00:00
|
|
|
|
|
|
|
|
CREATEAPPINSTANCE_JSON=$(cat <<EOF
|
|
|
|
|
{
|
|
|
|
|
"region": "${APP_REGION}",
|
|
|
|
|
"appinst": {
|
|
|
|
|
"key": {
|
2025-08-29 09:23:31 +00:00
|
|
|
"organization": "dev-framework",
|
2025-08-27 07:33:45 +00:00
|
|
|
"name": "$(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')-instance",
|
|
|
|
|
"cloudlet_key": {
|
|
|
|
|
"organization": "TelekomOP",
|
|
|
|
|
"name": "${CLOUDLET}"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"app_key": {
|
2025-08-29 09:23:31 +00:00
|
|
|
"organization": "dev-framework",
|
2025-08-27 07:33:45 +00:00
|
|
|
"name": "$(echo ${{ steps.repository.outputs.repository }} | sed -e 's|^.*/||')",
|
|
|
|
|
"version": "${{ steps.docker.outputs.version }}"
|
|
|
|
|
},
|
|
|
|
|
"flavor": {
|
|
|
|
|
"name": "${APP_FLAVOR}"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EOF
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
echo $CREATEAPPINSTANCE_JSON
|
|
|
|
|
|
|
|
|
|
echo create app instance
|
2025-09-15 15:24:19 +00:00
|
|
|
curl -X POST https://hub.apps.edge.platform.mg3.mdb.osc.live/api/v1/auth/ctrl/CreateAppInst -H 'Content-Type: application/json' -H "Authorization: Bearer $EDGEXR_TOKEN" -S --data "$CREATEAPPINSTANCE_JSON" --fail-with-body
|