publish related bits
This commit is contained in:
parent
9d863805ab
commit
18936e9511
@ -6,7 +6,7 @@
|
|||||||
#SET THESE VARIABLES OR NOTHING WILL WORK!!!!
|
#SET THESE VARIABLES OR NOTHING WILL WORK!!!!
|
||||||
|
|
||||||
export PipelineClientWorkingDir="D:/tsys/ReachableCEOPublic/MarketingMaterials/DSR/local"
|
export PipelineClientWorkingDir="D:/tsys/ReachableCEOPublic/MarketingMaterials/DSR/local"
|
||||||
export StakeholderOutputMarkdownInputFile="$1"
|
export StakeholderOutputMarkdownInputFile="$1"
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export StakeholderOutputMarkdownInputFile="$1"
|
|||||||
export ReportAuthor="Charles N Wyble"
|
export ReportAuthor="Charles N Wyble"
|
||||||
export AuthorTagline="Tenaciy. Velocity. Focus."
|
export AuthorTagline="Tenaciy. Velocity. Focus."
|
||||||
export AuthorLogo="D:/tsys/@ReachableCEO/ReachableCEO.png"
|
export AuthorLogo="D:/tsys/@ReachableCEO/ReachableCEO.png"
|
||||||
export SourceCode="https://git.knownelement.com/reachableceo/DSR_Pipeline-ReachableCEO"
|
export SourceCode="https://git.knownelement.com/reachableceo/DSR-Pipeline-ReachableCEO"
|
||||||
export URLCOLOR="blue"
|
export URLCOLOR="blue"
|
||||||
export PAGEBACKGROUND="$PipelineClientWorkingDir/build/background5.pdf"
|
export PAGEBACKGROUND="$PipelineClientWorkingDir/build/background5.pdf"
|
||||||
export PANDOC_TEMPLATE="eisvogel"
|
export PANDOC_TEMPLATE="eisvogel"
|
||||||
@ -31,8 +31,8 @@ export BUILD_TEMP_DIR="$PipelineClientWorkingDir/build-temp"
|
|||||||
export BUILD_OUTPUT_DIR="$PipelineClientWorkingDir/build-output"
|
export BUILD_OUTPUT_DIR="$PipelineClientWorkingDir/build-output"
|
||||||
export BUILDYAML_STAKEHOLDER_OUTPUT="$BUILD_TEMP_DIR/DSR.yml"
|
export BUILDYAML_STAKEHOLDER_OUTPUT="$BUILD_TEMP_DIR/DSR.yml"
|
||||||
|
|
||||||
export StakeholderOutputMarkdownOutputFile="$BUILD_OUTPUT_DIR/$(basename $StakeholderOutputMarkdownInputFile|awk -F '.' '{print $1}').md"
|
export StakeholderOutputMarkdownOutputFile="$BUILD_OUTPUT_DIR/$(basename $StakeholderOutputMarkdownInputFile|awk -F '.' '{print $1}').md"
|
||||||
export StakeholderOutputPDFOutputFile="$BUILD_OUTPUT_DIR/$(basename $StakeholderOutputMarkdownInputFile|awk -F '.' '{print $1}').pdf"
|
export StakeholderOutputPDFOutputFile="$BUILD_OUTPUT_DIR/$(basename $StakeholderOutputMarkdownInputFile|awk -F '.' '{print $1}').pdf"
|
||||||
|
|
||||||
###################################################################
|
###################################################################
|
||||||
# Publish variables
|
# Publish variables
|
||||||
@ -43,4 +43,5 @@ export BITWARDEN_CREDS="D:/tsys/secrets/bitwarden/data/apikey-bitwarden-reachabl
|
|||||||
export DISCOURSE_URL="https://community.turnsys.com"
|
export DISCOURSE_URL="https://community.turnsys.com"
|
||||||
export DISCOURSE_API_USERNAME="reachableceo"
|
export DISCOURSE_API_USERNAME="reachableceo"
|
||||||
export DISCOURSE_CATEGORY_ID="61"
|
export DISCOURSE_CATEGORY_ID="61"
|
||||||
export DISCOURSE_POST_TITLE="Daily Stakeholder Report"
|
export TODAY_DATE="$(date +%m-%d-%Y)"
|
||||||
|
export DISCOURSE_POST_TITLE="Daily Stakeholder Report for $TODAY_DATE"
|
@ -1,5 +1,7 @@
|
|||||||
title: "Daily Stakeholder Report for {{ReportAuthor}}"
|
title: "Daily Stakeholder Report for {{ReportAuthor}}"
|
||||||
titlepage: true
|
titlepage: true
|
||||||
|
toc: true
|
||||||
|
toc-own-page: true
|
||||||
titlepage-logo: "{{CandidateLogo}}"
|
titlepage-logo: "{{CandidateLogo}}"
|
||||||
header-left: "\\hspace{1cm}"
|
header-left: "\\hspace{1cm}"
|
||||||
header-center: "\\leftmark"
|
header-center: "\\leftmark"
|
||||||
|
75
local/build/publish-dsr.sh
Normal file
75
local/build/publish-dsr.sh
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
source ../DSRVariables.env
|
||||||
|
|
||||||
|
echo "Obtaining discourse api key..."
|
||||||
|
bw logout
|
||||||
|
bw config server "$BITWARDEN_SERVER_URL"
|
||||||
|
source "$BITWARDEN_CREDS"
|
||||||
|
bw login --apikey $BW_CLIENTID $BW_CLIENTSECRET
|
||||||
|
export BW_SESSION="$(bw unlock --passwordenv TSYS_BW_PASSWORD_REACHABLECEO --raw)"
|
||||||
|
export DISCOURSE_API_KEY="$(bw get password APIKEY-discourse)"
|
||||||
|
|
||||||
|
echo "Posting DSR..."
|
||||||
|
|
||||||
|
# The content of the post
|
||||||
|
CONTENT="Please use the link below to download today's stakeholder report."
|
||||||
|
|
||||||
|
# The file to upload (from the second argument or auto-generated based on date)
|
||||||
|
FILE_PATH="$StakeholderOutputPDFOutputFile"
|
||||||
|
|
||||||
|
# Check if the file exists
|
||||||
|
if [ ! -f "$FILE_PATH" ]; then
|
||||||
|
echo "File not found: $FILE_PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Upload the file
|
||||||
|
echo "Uploading file..."
|
||||||
|
upload_response=$(curl -s -X POST "$DISCOURSE_URL/uploads.json" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-H "Api-Key: $DISCOURSE_API_KEY" \
|
||||||
|
-H "Api-Username: $DISCOURSE_API_USERNAME" \
|
||||||
|
-F "file=@$FILE_PATH;type=application/pdf" \
|
||||||
|
-F "type=composer")
|
||||||
|
|
||||||
|
echo "Upload Response: $upload_response"
|
||||||
|
|
||||||
|
# Extract the short_url from the response
|
||||||
|
short_url=$(echo "$upload_response" | /mingw64/bin/jq -r '.short_url')
|
||||||
|
|
||||||
|
# Check if the short_url was returned
|
||||||
|
if [ "$short_url" == "null" ]; then
|
||||||
|
echo "Failed to extract short_url. Response:"
|
||||||
|
echo "$upload_response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "File uploaded successfully. Short URL: $short_url"
|
||||||
|
|
||||||
|
# Append the file link to the post content (Markdown format)
|
||||||
|
CONTENT="$CONTENT\n\n[Download todays report in PDF format]($short_url)"
|
||||||
|
|
||||||
|
# Create the new topic
|
||||||
|
echo "Creating new topic..."
|
||||||
|
post_response=$(curl -s -X POST "$DISCOURSE_URL/posts.json" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Api-Key: $DISCOURSE_API_KEY" \
|
||||||
|
-H "Api-Username: $DISCOURSE_API_USERNAME" \
|
||||||
|
-d @- <<EOF
|
||||||
|
{
|
||||||
|
"title": "$DISCOURSE_POST_TITLE",
|
||||||
|
"raw": "$CONTENT",
|
||||||
|
"category": $DISCOURSE_CATEGORY_ID
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "Post Response: $post_response"
|
||||||
|
|
||||||
|
# Check if the post creation was successful
|
||||||
|
if echo "$post_response" | grep -q '"id":'; then
|
||||||
|
echo "Post created successfully!"
|
||||||
|
else
|
||||||
|
echo "Failed to create post. Response:"
|
||||||
|
echo "$post_response"
|
||||||
|
exit 1
|
||||||
|
fi
|
Loading…
Reference in New Issue
Block a user