Skip to content

Skms integration

Skms integration #13

Workflow file for this run

name: Create CMR in SKMS
on:
pull_request:
types:
- closed
branches:
- skms-release-test
jobs:
create-cmr:
# Only run this workflow on pull requests that have merged and not manually closed by user
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Runs a single command using the runners shell for shell validation
- name: Run a one-line script
run: echo Starting CMR Action...
# Run command for creating CMR in SKMS system
- run: |
start_date=$(TZ=":America/Los_Angeles" date '+%Y-%m-%d %H:%M')
DEFAULT_SKMS_URL='api.skms.adobe.com'
function skms_request() {
local username=$1
local passkey=$2
local object=$3
local method=$4
local method_params=$5
local url=$6
if [ -z "$username" ]; then
echo "First parameter missing, must be SKMS username"
return 1
fi
if [ -z "$passkey" ]; then
echo "Second parameter missing, must be SKMS passkey"
return 1
fi
if [ -z "$object" ]; then
echo "Third parameter missing, must be an SKMS dao object"
return 1
fi
if [ -z "$method" ]; then
echo "Fourth parameter missing, must be SKMS dao method"
return 1
fi
if [ -z "$method_params" ]; then
method_params='{}'
fi
if [ -z "$url" ]; then
url=$DEFAULT_SKMS_URL
fi
if ! type "jq" >/dev/null; then
echo "jq is required but not installed"
fi
if ! type "curl" >/dev/null; then
echo "curl is required but not installed"
fi
local params="{\"_username\":\"${username}\",\"_passkey\":\"${passkey}\",\"_object\":\"${object}\",\"_method\": \"${method}\"}"
params=$(echo "$params $method_params" | jq -s add)
curl https://${url}/web_api --data-urlencode "_parameters=${params}"
echo ''
}
end_date=$(TZ=":America/Los_Angeles" date '+%Y-%m-%d %H:%M')
release_details="${{ github.event.pull_request.body }}"
release_details="${release_details//$'\r\n'/ }"
skms_request '${{ secrets.SKMS_USER }}' '${{ secrets.SKMS_PASS }}' CmrDao createCmrFromPreapprovedChangeModel '{"change_executor":"${{ github.actor }}","maintenance_window_end_time":"${end_date}","maintenance_window_start_time":"${start_date}","preapproved_change_model_id":847787,"summary":"Release Title:${{ github.event.pull_request.title }}::${release_details}::Pull Request #${{ github.event.pull_request.number }}::Pull Request Created at:${{ github.event.pull_request.created_at }}::Pull Request Merged at:${{ github.event.pull_request.merged_at }}"}'