Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skms integration #1202

Merged
merged 99 commits into from
Sep 2, 2023
Merged
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
bfcc49f
SKMS CI integration start
amauch-adobe Apr 21, 2023
61731d9
removed pull request flow
amauch-adobe May 20, 2023
0b40daf
changed branch for testing
amauch-adobe May 24, 2023
de86cf1
filled in the values for stage testing
amauch-adobe May 24, 2023
77aada2
temp stage pass
amauch-adobe May 24, 2023
73c0a53
updated skms call
amauch-adobe May 25, 2023
53cc13a
Updated skms.yaml to pull request event
amauch-adobe May 31, 2023
719a277
cleaned up, formatted, updated condition
amauch-adobe Jul 21, 2023
6518ea6
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
9811dae
Skms integration (#969)
amauch-adobe Jul 21, 2023
7d5b42a
added missing curly brace
amauch-adobe Jul 21, 2023
af1736d
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
3cb103e
Skms integration (#972)
amauch-adobe Jul 21, 2023
ab37785
fixing conflicts
amauch-adobe Jul 21, 2023
f428e53
Fixing JSON Parsing
amauch-adobe Jul 21, 2023
a7ce2f8
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
d4d02cc
Skms integration (#973)
amauch-adobe Jul 21, 2023
51b8d80
fixing missing quotes, cleaned up summary
amauch-adobe Jul 21, 2023
8b3bf6e
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
9c5dca9
Skms integration (#974)
amauch-adobe Jul 21, 2023
5187652
debugging JSON Parsing
amauch-adobe Jul 21, 2023
4ba014a
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
8690d1a
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
06fa12f
Skms integration (#975)
amauch-adobe Jul 21, 2023
01f5a27
debugging echos
amauch-adobe Jul 21, 2023
11c1fb2
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
1a551a1
Skms integration (#976)
amauch-adobe Jul 21, 2023
1c7311d
removing line breaks for JSON Parsing
amauch-adobe Jul 21, 2023
b5e240e
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
94731c2
Skms integration (#977)
amauch-adobe Jul 21, 2023
ed91ea6
testing and debugging
amauch-adobe Jul 21, 2023
c510ec5
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
8a9ce5c
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
19933cd
Skms integration (#978)
amauch-adobe Jul 21, 2023
44860e9
testing new line removal
amauch-adobe Jul 21, 2023
5e4a59e
Skms integration (#980)
amauch-adobe Jul 21, 2023
1bf72d7
gave back spacing
amauch-adobe Jul 21, 2023
9ae1f99
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
283b6f9
Skms integration (#981)
amauch-adobe Jul 21, 2023
5c92119
added comma delimited new lines
amauch-adobe Jul 21, 2023
6461a4f
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
52c57c8
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
0eaa0b5
Skms integration (#982)
amauch-adobe Jul 21, 2023
7361cfb
adding spaces for new lines for JSON parser
amauch-adobe Jul 21, 2023
02d9b2d
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
9aafe68
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Jul 21, 2023
8949800
updated workflow name, branch list, api url
amauch-adobe Jul 21, 2023
50f2f49
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 21, 2023
a2cb0f8
Merge branch 'main' into skms-integration
amauch-adobe Jul 21, 2023
7df197f
Merge branch 'main' into skms-integration
amauch-adobe Jul 25, 2023
17e19b4
Removed boiler plate comments
amauch-adobe Jul 25, 2023
22e3860
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Jul 25, 2023
b62244e
Merge branch 'main' into skms-integration
amauch-adobe Jul 25, 2023
b88218e
switched secrets to production ones
amauch-adobe Jul 25, 2023
c4c0b95
testing int vs string
amauch-adobe Jul 27, 2023
a697d31
Merge branch 'main' into skms-integration
amauch-adobe Jul 27, 2023
59265a6
Merge branch 'main' into skms-integration
amauch-adobe Jul 31, 2023
7da0e9b
moved dependency check
amauch-adobe Jul 31, 2023
ace50d2
moved curl call into a response wrapper
amauch-adobe Aug 1, 2023
6c14924
updated curl call wrapper
amauch-adobe Aug 1, 2023
43335ca
small fix to wrapper again
amauch-adobe Aug 1, 2023
286ae1d
fixing failure for command
amauch-adobe Aug 1, 2023
ded9545
testing curl write out
amauch-adobe Aug 1, 2023
82d8b43
updating response output from curl
amauch-adobe Aug 1, 2023
4994729
more clear error messaging
amauch-adobe Aug 1, 2023
65e48b8
added exit status, fixed typo
amauch-adobe Aug 1, 2023
75d6fde
added quote santization
amauch-adobe Aug 1, 2023
9f2f995
Merge branch 'main' into skms-integration
amauch-adobe Aug 1, 2023
3834d2b
Fixing skms api call and removal of quotes
amauch-adobe Aug 2, 2023
e308223
Merge branch 'skms-integration' of https://github.com/adobecom/milo i…
amauch-adobe Aug 2, 2023
dadf4f1
Merge branch 'skm-release-test' into skms-integration
amauch-adobe Aug 2, 2023
d8d3da7
Merge branch 'main' into skms-integration
amauch-adobe Aug 2, 2023
d44d7e2
parameter expansion pattern removal added
amauch-adobe Aug 2, 2023
9bfc65a
instead of removing we will be escaping quotes
amauch-adobe Aug 2, 2023
bb7d7b3
remove quotes immediately
amauch-adobe Aug 2, 2023
f26de95
returned escaped quotes
amauch-adobe Aug 2, 2023
cf1f851
added echo statements
amauch-adobe Aug 2, 2023
1e5f397
updated url
amauch-adobe Aug 2, 2023
491ad33
added removal of single quote
amauch-adobe Aug 2, 2023
0f4144a
same
amauch-adobe Aug 2, 2023
acebad8
added sanitizeStr()
amauch-adobe Aug 2, 2023
50d85f1
added removal of tabs
amauch-adobe Aug 2, 2023
01735ca
removed echo statements
amauch-adobe Aug 2, 2023
b8b87ae
Merge branch 'main' into skms-integration
amauch-adobe Aug 2, 2023
0d108d6
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Aug 4, 2023
dd158ad
added github action secret for two new variables
amauch-adobe Aug 4, 2023
52d8caa
Merge branch 'main' into skms-integration
amauch-adobe Aug 15, 2023
e339025
added back github.actor parameter
amauch-adobe Aug 17, 2023
9ecd31d
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Aug 17, 2023
c5b1e30
added single quotes around CL params
amauch-adobe Aug 22, 2023
5b57765
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Aug 22, 2023
01f5ec3
removed accidental double single quotes
amauch-adobe Aug 22, 2023
d411ca5
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Aug 22, 2023
41878a3
removed single quotes and escaped double quotes
amauch-adobe Aug 22, 2023
103e794
second attempt
amauch-adobe Aug 22, 2023
df8bcb8
fixing quote escaping
amauch-adobe Aug 22, 2023
9c96222
switching to use jq
amauch-adobe Sep 2, 2023
0ce84e7
Merge branch 'skms-release-test' into skms-integration
amauch-adobe Sep 2, 2023
67822fb
debug statements added for testing
amauch-adobe Sep 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions .github/workflows/skms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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 -d "5 minutes ago" '+%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 mw_start_time=$5
local mw_end_time=$6
local change_summary=$7
local method_params=$8
local url=$9

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 "$mw_start_time" ]; then
echo "Fifth parameter missing, must be a formatted datetime"
return 1
fi

if [ -z "$mw_end_time" ]; then
echo "Sixth parameter missing, must be a formatted datetime"
return 1
fi

if [ -z "$change_summary" ]; then
echo "Seventh parameter missing, must be a SKMS summary text"
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}\",\"maintenance_window_start_time\":\"${mw_start_time}\",\"maintenance_window_end_time\":\"${mw_end_time}\",\"summary\":\"${change_summary}\"}"
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 }}")
summary=Release_Title-"$release_title"--"$release_details"--PR_Number-"${{ github.event.pull_request.number }}"--PR_Created_At-"${{ github.event.pull_request.created_at }}"--PR_Merged_At-"${{ github.event.pull_request.merged_at }}"
echo "$start_date"
echo "$end_date"
echo "$summary"

skms_request '${{ secrets.SKMS_USER }}' '${{ secrets.SKMS_PASS }}' CmrDao createCmrFromPreapprovedChangeModel '${start_date}' '${end_date}' '${summary}' '{"change_executor":"${{ github.actor }}","preapproved_change_model_id":"${{ secrets.SKMS_CHANGE_MODEL_ID }}"}'
Loading