85 lines
No EOL
2.7 KiB
YAML
85 lines
No EOL
2.7 KiB
YAML
name: createapp
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
a_app_version:
|
|
type: string
|
|
description: "Application Version e.g. 1.0.0"
|
|
required: true
|
|
b_app_region:
|
|
type: string
|
|
description: "Application Region e.g. EU"
|
|
default: EU
|
|
c_app_flavor:
|
|
type: string
|
|
description: "Application Flavor e.g. EU.small"
|
|
default: EU.small
|
|
|
|
env:
|
|
EDGEXR_PLATFORM_USERNAME: ${{ secrets.EDGEXR_PLATFORM_USERNAME }}
|
|
EDGEXR_PLATFORM_PASSWORD: ${{ secrets.EDGEXR_PLATFORM_PASSWORD }}
|
|
APP_VERSION: ${{ inputs.a_app_version }}
|
|
APP_REGION: ${{ inputs.b_app_region }}
|
|
APP_FLAVOR: ${{ inputs.c_app_flavor }}
|
|
|
|
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 }}
|
|
-
|
|
name: Install Curl
|
|
run: |
|
|
sudo apt update
|
|
sudo apt install -y curl jq
|
|
-
|
|
name: Create edgeXR App
|
|
run: |
|
|
set -e
|
|
echo login
|
|
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)"
|
|
|
|
CREATEAPP_JSON=$(cat <<EOF
|
|
{
|
|
"App": {
|
|
"key": {
|
|
"organization": "edp-developer-framework",
|
|
"name": "${{ steps.repository.outputs.repository }}",
|
|
"version": "${APP_VERSION}"
|
|
},
|
|
"image_path": "${{ steps.docker.outputs.tags }}",
|
|
"image_type": "Docker",
|
|
"access_ports": "tcp:80",
|
|
"default_flavor": {
|
|
"name": "${APP_FLAVOR}"
|
|
},
|
|
"deployment": "docker",
|
|
"required_outbound_connections": null
|
|
},
|
|
"Region": "${APP_REGION}"
|
|
}
|
|
EOF
|
|
)
|
|
|
|
echo $CREATEAPP_JSON
|
|
|
|
echo create app
|
|
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" -Sf --data "$CREATEAPP_JSON" |