Skip to content

Commit

Permalink
Skms integration (#1138)
Browse files Browse the repository at this point in the history
* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* Skms integration (#969)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* Skms integration (#972)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* Skms integration (#973)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* Skms integration (#974)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* Skms integration (#975)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* Skms integration (#976)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* Skms integration (#977)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* testing and debugging

* Skms integration (#978)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* testing and debugging

* testing new line removal

testing new line removal

* Skms integration (#980)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* testing and debugging

* testing new line removal

testing new line removal

* gave back spacing

gave back spacing

* Skms integration (#981)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* testing and debugging

* testing new line removal

testing new line removal

* gave back spacing

gave back spacing

* added comma delimited new lines

added comma delimited new lines

* Skms integration (#982)

* SKMS CI integration start

SKMS CI integration start

* removed pull request flow

removed pull request flow

* changed branch for testing

changed branch for testing

* filled in the values for stage testing

filled in the values for stage testing

* temp stage pass

temp stage pass

* updated skms call

updated skms call

* Updated skms.yaml to pull request event

changed event type to pull request, updated logic to only run when merged, added summary variable from github context.

* cleaned up, formatted, updated condition

cleaned up, formatted, updated condition so that if statement is not on shell but on github actions.

* added missing curly brace

added missing curly brace

* fixing conflicts

fixing conflicts

* Fixing JSON Parsing

Fixing JSON Parsing

* fixing missing quotes, cleaned up summary

fixing missing quotes, cleaned up summary

* debugging JSON Parsing

debugging JSON Parsing

* debugging echos

debugging echos

* removing line breaks for JSON Parsing

removing line breaks for JSON Parsing

* testing and debugging

* testing new line removal

testing new line removal

* gave back spacing

gave back spacing

* added comma delimited new lines

added comma delimited new lines

* adding spaces for new lines for JSON parser

adding spaces for new lines for JSON parser

* updated workflow name, branch list, api url

updated workflow name, branch list, api url

* Removed boiler plate comments

Removed boiler plate comments

* switched secrets to production ones

switched secrets to production ones

* testing int vs string

testing int vs string since API requires int.

* moved dependency check

moved dependency check to separate job execution

* moved curl call into a response wrapper

moved curl call into a response wrapper

* updated curl call wrapper

updated curl call wrapper

* small fix to wrapper again

small fix to wrapper again

* fixing failure for command

fixing failure for command

* testing curl write out

* updating response output from curl

updating response output from curl

* more clear error messaging

more clear error messaging

* added exit status, fixed typo

added exit status, fixed typo

* added quote santization

added quote sanitization

* Fixing skms api call and removal of quotes

Fixing skms api call and removal of quotes

* parameter expansion pattern removal added

parameter expansion pattern removal added

* instead of removing we will be escaping quotes

instead of removing we will be escaping quotes

* remove quotes immediately

remove quotes immediately

* returned escaped quotes

returned escaped quotes

* added echo statements

* updated url

* added removal of single quote

added removal of single quote

* same

* added sanitizeStr()

added sanitizeStr()

* added removal of tabs

added removal of tabs

* removed echo statements

removed echo statements

* added github action secret for two new variables

added github action secret for change model id and change executor so those can be added dynamically for other teams and for changes in the future.

* added back github.actor parameter

added back github.actor parameter so that change executor is associated to workflow executors.

* added single quotes around CL params

added single quotes around CL params

* removed accidental double single quotes

removed accidental double single quotes
  • Loading branch information
amauch-adobe authored Aug 22, 2023
1 parent 6eba19b commit 0703cb5
Showing 1 changed file with 115 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/skms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
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...

# Validate dependencies before continuing CMR creation
- name: Check Dependencies
run: |
if ! type "jq" >/dev/null; then
echo "jq is required but not installed"
exit 1
fi
if ! type "curl" >/dev/null; then
echo "curl is required but not installed"
exit 1
fi
echo "Dependencies check was successful"
# 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
local params="{\"_username\":\"${username}\",\"_passkey\":\"${passkey}\",\"_object\":\"${object}\",\"_method\": \"${method}\"}"
params=$(echo "$params $method_params" | jq -s add)
local response=$(curl --write-out "%{http_code}" --silent --output response.txt https://${url}/web_api --data-urlencode "_parameters=${params}")
if [ $response != "200" ]; then
echo "CURL call returned HTTP status code: $response"
exit 1
elif grep -q "\"status\":\"error\"" response.txt; then
echo "CMR creation failed with response: "
cat response.txt
exit 1
else
echo "CMR creation was successful"
fi
}
function sanitizeStr() {
local str=$1
if [ -z "$str" ]; then
echo "First parameter missing, must be a valid string"
return 1
fi
str="${str//\"/""}"
str="${str//\'/""}"
str="${str//$'\r\n\t'/ }"
echo "$str"
}
end_date=$(TZ=":America/Los_Angeles" date '+%Y-%m-%d %H:%M')
release_title=$(sanitizeStr "${{ github.event.pull_request.title }}")
release_details=$(sanitizeStr "${{ github.event.pull_request.body }}")
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":"${{ secrets.SKMS_CHANGE_MODEL_ID }}","summary":"Release Title:'${release_title}'::'${release_details}'::Pull Request Number:${{ 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 }}"}'

0 comments on commit 0703cb5

Please sign in to comment.