diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml index 3dcf02f..1ad39a8 100644 --- a/.gitea/workflows/publish.yaml +++ b/.gitea/workflows/publish.yaml @@ -2,6 +2,11 @@ name: Publish ApplicationRecord to Registry on: release: types: [published] + +env: + CERC_REGISTRY_USER_KEY: ${{ secrets.CICD_LACONIC_USER_KEY }} + CERC_REGISTRY_BOND_ID: ${{ secrets.CICD_LACONIC_BOND_ID }} + jobs: cns_publish: runs-on: ubuntu-latest @@ -21,14 +26,6 @@ jobs: - name: "Install jq" run: apt -y update && apt -y install jq - name: "Publish Application Record" - env: - CERC_REGISTRY_USER_KEY: ${{ secrets.CICD_LACONIC_USER_KEY }} - CERC_REGISTRY_BOND_ID: ${{ secrets.CICD_LACONIC_USER_KEY }} - 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/request-app-deployment.sh diff --git a/scripts/publish-app-record.sh b/scripts/publish-app-record.sh index 66a621e..5edc2de 100755 --- a/scripts/publish-app-record.sh +++ b/scripts/publish-app-record.sh @@ -54,13 +54,17 @@ 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 -if [ -n "$CERC_REGISTRY_APP_CRN" ]; then - laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@${rcd_app_version}" "$RECORD_ID" - laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@${CERC_REPO_REF}" "$RECORD_ID" - if [ "true" == "$CERC_IS_LATEST_RELEASE" ]; then - laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN" "$RECORD_ID" - laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@latest" "$RECORD_ID" - fi +if [ -z "$CERC_REGISTRY_APP_CRN" ]; then + authority=$(echo "$rcd_name" | cut -d'/' -f1 | sed 's/@//') + app=$(echo "$rcd_name" | cut -d'/' -f2-) + CERC_REGISTRY_APP_CRN="crn://$authority/applications/$app" +fi + +laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@${rcd_app_version}" "$RECORD_ID" +laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@${CERC_REPO_REF}" "$RECORD_ID" +if [ "true" == "$CERC_IS_LATEST_RELEASE" ]; then + laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN" "$RECORD_ID" + laconic -c $CONFIG_FILE cns name set --user-key "${CERC_REGISTRY_USER_KEY}" --bond-id ${CERC_REGISTRY_BOND_ID} "$CERC_REGISTRY_APP_CRN@latest" "$RECORD_ID" fi rm -f $RECORD_FILE $CONFIG_FILE diff --git a/scripts/request-app-deployment.sh b/scripts/request-app-deployment.sh index d4500f1..73f5e48 100755 --- a/scripts/request-app-deployment.sh +++ b/scripts/request-app-deployment.sh @@ -19,8 +19,9 @@ services: EOF if [ -z "$CERC_REGISTRY_APP_CRN" ]; then - echo "CERC_REGISTRY_APP_CRN is required." 1>&2 - exit 1 + authority=$(echo "$rcd_name" | cut -d'/' -f1 | sed 's/@//') + app=$(echo "$rcd_name" | cut -d'/' -f2-) + CERC_REGISTRY_APP_CRN="crn://$authority/applications/$app" fi APP_RECORD=$(laconic -c $CONFIG_FILE cns name resolve "$CERC_REGISTRY_APP_CRN" | jq '.[0]')