Add request-app-deployment.sh (#8)

![image](/attachments/237ace77-c3b6-4151-8559-a1826dcdfc9d)

Reviewed-on: #8
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
This commit is contained in:
Thomas E Lackey 2023-12-14 03:52:24 +00:00 committed by Thomas E Lackey
parent b9658f79c7
commit bee6fae753
4 changed files with 61 additions and 4 deletions

View File

@ -20,9 +20,15 @@ jobs:
yarn global add @cerc-io/laconic-registry-cli
- name: "Install jq"
run: apt -y update && apt -y install jq
- name: "Publish Record"
- name: "Publish Application Record"
env:
CERC_REGISTRY_USER_KEY: ${{ secrets.CICD_CERCIO_USER_KEY }}
CERC_REGISTRY_BOND_ID: ${{ secrets.CICD_CERCIO_BOND_ID }}
CERC_REGISTRY_APP_CRN: "crn://cerc-io/applications/test-progressive-web-app"
run: scripts/publish-app-record.sh
- name: "Request Deployment"
env:
CERC_REGISTRY_USER_KEY: ${{ secrets.CICD_LACONIC_USER_KEY }}
CERC_REGISTRY_BOND_ID: ${{ secrets.CICD_LACONIC_BOND_ID }}
CERC_REGISTRY_APP_CRN: "crn://cerc-io/applications/test-progressive-web-app"
run: scripts/publish-app-record.sh
run: scripts/request-app-deployment.sh

View File

@ -1,7 +1,7 @@
{
"private": true,
"name": "@cerc-io/test-progressive-web-app",
"version": "0.1.1",
"version": "0.1.2",
"repository": "https://git.vdb.to/cerc-io/test-progressive-web-app",
"scripts": {
"dev": "next dev",

View File

@ -42,7 +42,8 @@ record:
homepage: "$rcd_homepage"
license: "$rcd_license"
author: "$rcd_author"
repository: "$rcd_repository"
repository:
- "$rcd_repository"
repository_ref: "$CERC_REPO_REF"
app_version: "$rcd_app_version"
app_type: "$CERC_APP_TYPE"

View File

@ -0,0 +1,50 @@
#!/bin/bash
set -e
RECORD_FILE=tmp.rf.$$
CONFIG_FILE=`mktemp`
rcd_name=$(jq -r '.name' package.json | sed 's/null//' | sed 's/^@//')
rcd_app_version=$(jq -r '.version' package.json | sed 's/null//')
cat <<EOF > "$CONFIG_FILE"
services:
cns:
restEndpoint: '${CERC_REGISTRY_REST_ENDPOINT:-http://console.laconic.com:1317}'
gqlEndpoint: '${CERC_REGISTRY_GQL_ENDPOINT:-http://console.laconic.com:9473/api}'
chainId: ${CERC_REGISTRY_CHAIN_ID:-laconic_9000-1}
gas: 550000
fees: 200000aphoton
EOF
if [ -z "$CERC_REGISTRY_APP_CRN" ]; then
echo "CERC_REGISTRY_APP_CRN is required." 1>&2
exit 1
fi
APP_RECORD=$(laconic -c $CONFIG_FILE cns name resolve "$CERC_REGISTRY_APP_CRN" | jq '.[0]')
if [ -z "$APP_RECORD" ] || [ "null" == "$APP_RECORD" ]; then
echo "No record found for $CERC_REGISTRY_APP_CRN."
exit 1
fi
cat <<EOF | sed '/.*: ""$/d' > "$RECORD_FILE"
record:
type: ApplicationDeploymentRequest
version: 1.0.0
name: "$rcd_name@$rcd_app_version"
application: "$CERC_REGISTRY_APP_CRN@$rcd_app_version"
dns: "$CERC_REGISTRY_DEPLOYMENT_SHORT_HOSTNAME"
deployment: "$CERC_REGISTRY_DEPLOYMENT_CRN"
meta:
note: "Added by CI"
repository: "`git remote get-url origin`"
repository_ref: "${GITHUB_SHA:-`git log -1 --format="%H"`}"
EOF
cat $RECORD_FILE
RECORD_ID=$(laconic -c $CONFIG_FILE cns record publish --filename $RECORD_FILE --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} | jq -r '.id')
echo $RECORD_ID
rm -f $RECORD_FILE $CONFIG_FILE