Moving to microservice client/server model
This commit is contained in:
12
dsr-publish/2025Plan.yml
Normal file
12
dsr-publish/2025Plan.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
title: ReachableCEO 2025 Plan
|
||||
titlepage: true
|
||||
toc: true
|
||||
toc-own-page: true
|
||||
header-left: "\\hspace{1cm}"
|
||||
header-center: "\\leftmark"
|
||||
header-right: "Page \\thepage"
|
||||
footer-left: "Charles N Wyble"
|
||||
footer-center: "Tenacity. Velocity. Focus."
|
||||
page-background: "./background5.pdf"
|
||||
titlepage-logo: "D:/tsys/@ReachableCEO/ReachableCEO.png"
|
||||
urlcolor: blue
|
70
dsr-publish/background5.pdf
Normal file
70
dsr-publish/background5.pdf
Normal file
@@ -0,0 +1,70 @@
|
||||
%PDF-1.5
|
||||
%<25><><EFBFBD><EFBFBD>
|
||||
3 0 obj
|
||||
<< /Length 4 0 R
|
||||
/Filter /FlateDecode
|
||||
>>
|
||||
stream
|
||||
x<EFBFBD>m<EFBFBD>;<0E>@D<>=<3D>/<2F><><EFBFBD><EFBFBD><EFBFBD>18 <14><>K삢D
|
||||
r<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ư<EFBFBD>0f<EFBFBD><EFBFBD>|%<25>߅ <20>1<EFBFBD><31><EFBFBD><EFBFBD>D<EFBFBD><44>g,7<>
|
||||
!<21>i<03>jҔ<6A>P <09>/c<>h<06>px<70>r<72><C289><EFBFBD><EFBFBD>1W<31>^<5E><>Q<EFBFBD>d<>%q<>!<21><>9ZD<12>j<EFBFBD><6A>
|
||||
U<EFBFBD>Ѫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>A<EFBFBD>p<EFBFBD><EFBFBD>r$<24>&]x_<78><5F>ʑȽ<CA91>I<EFBFBD>W<><7F>?f<>r)<1F>6EU
|
||||
endstream
|
||||
endobj
|
||||
4 0 obj
|
||||
168
|
||||
endobj
|
||||
2 0 obj
|
||||
<<
|
||||
/ExtGState <<
|
||||
/a0 << /CA 1 /ca 1 >>
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<< /Type /Page
|
||||
/Parent 1 0 R
|
||||
/MediaBox [ 0 0 595.275574 841.889771 ]
|
||||
/Contents 3 0 R
|
||||
/Group <<
|
||||
/Type /Group
|
||||
/S /Transparency
|
||||
/I true
|
||||
/CS /DeviceRGB
|
||||
>>
|
||||
/Resources 2 0 R
|
||||
>>
|
||||
endobj
|
||||
1 0 obj
|
||||
<< /Type /Pages
|
||||
/Kids [ 5 0 R ]
|
||||
/Count 1
|
||||
>>
|
||||
endobj
|
||||
6 0 obj
|
||||
<< /Creator (cairo 1.14.8 (http://cairographics.org))
|
||||
/Producer (cairo 1.14.8 (http://cairographics.org))
|
||||
>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<< /Type /Catalog
|
||||
/Pages 1 0 R
|
||||
>>
|
||||
endobj
|
||||
xref
|
||||
0 8
|
||||
0000000000 65535 f
|
||||
0000000582 00000 n
|
||||
0000000282 00000 n
|
||||
0000000015 00000 n
|
||||
0000000260 00000 n
|
||||
0000000354 00000 n
|
||||
0000000647 00000 n
|
||||
0000000774 00000 n
|
||||
trailer
|
||||
<< /Size 8
|
||||
/Root 7 0 R
|
||||
/Info 6 0 R
|
||||
>>
|
||||
startxref
|
||||
826
|
14
dsr-publish/create-2025Plan.sh
Normal file
14
dsr-publish/create-2025Plan.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
INPUT_FILE="../dsr-build-temp/@DailyStakeholderReports/StrategicPlans/2025-ReachableCEO-Plan.md"
|
||||
OUTPUT_FILE="../dsr-build-output/ReachableCEO2025Plan.pdf"
|
||||
METADATA_FILE="2025Plan.yml"
|
||||
TEMPLATE="eisvogel"
|
||||
|
||||
pandoc \
|
||||
$INPUT_FILE \
|
||||
--template $TEMPLATE \
|
||||
--metadata-file=$METADATA_FILE \
|
||||
--from markdown \
|
||||
--to=pdf \
|
||||
--output $OUTPUT_FILE
|
17
dsr-publish/create-dsr-pdf.sh
Normal file
17
dsr-publish/create-dsr-pdf.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
TODAY_DATE=$(date +%m-%d-%Y)
|
||||
INPUT_FILE="DSR-$TODAY_DATE.md"
|
||||
OUTPUT_FILE="/d/tsys/@ReachableCEO/DailyStakeholderReport-Pipeline/dsr-build-output/DSR-$TODAY_DATE.pdf"
|
||||
METADATA_FILE="/d/tsys/@ReachableCEO/DailyStakeholderReport-Pipeline/dsr-publish/daily-stakeholder-report.yml"
|
||||
TEMPLATE="eisvogel"
|
||||
|
||||
cd /d/tsys/@ReachableCEO/DailyStakeholderReport-Pipeline/dsr-build-temp/@DailyStakeholderReports/Today || exit
|
||||
|
||||
pandoc \
|
||||
$INPUT_FILE \
|
||||
--template $TEMPLATE \
|
||||
--metadata-file=$METADATA_FILE \
|
||||
--from markdown \
|
||||
--to=pdf \
|
||||
--output $OUTPUT_FILE
|
11
dsr-publish/daily-stakeholder-report.yml
Normal file
11
dsr-publish/daily-stakeholder-report.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
title: Daily Stakeholder Report - \today
|
||||
urlcolor: blue
|
||||
titlepage: true
|
||||
header-left: "\\hspace{1cm}"
|
||||
header-center: "\\leftmark"
|
||||
header-right: "Page \\thepage"
|
||||
footer-left: "Charles N Wyble"
|
||||
footer-center: "Tenacity. Velocity. Focus."
|
||||
footer-right: "[Source code](https://git.knownelement.com/reachableceo/DailyStakeholderReport-Pipeline/src/branch/main/dsr-publish/create-dsr-pdf.sh)"
|
||||
page-background: "D:/tsys/@ReachableCEO/DailyStakeholderReport-Pipeline/dsr-publish/background5.pdf"
|
||||
titlepage-logo: "D:/tsys/@ReachableCEO/ReachableCEO.png"
|
131
dsr-publish/publish-dsr.sh
Normal file
131
dsr-publish/publish-dsr.sh
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/bin/bash
|
||||
|
||||
secrets_manager()
|
||||
{
|
||||
|
||||
echo "Obtaining discourse api key..."
|
||||
|
||||
bw logout
|
||||
|
||||
####################################
|
||||
## Step 0: Set to use tsys server
|
||||
####################################
|
||||
bw config server https://pwvault.turnsys.com
|
||||
|
||||
####################################
|
||||
## Step 1: login to bitwarden
|
||||
####################################
|
||||
|
||||
# From: https://bitwarden.com/help/cli/#using-an-api-key
|
||||
|
||||
### Set apikey environment varaible
|
||||
|
||||
source D:/tsys/secrets/bitwarden/data/apikey-bitwarden-reachableceo
|
||||
|
||||
### Login to vault using apikey...
|
||||
|
||||
bw login --apikey $BW_CLIENTID $BW_CLIENTSECRET
|
||||
|
||||
### Step 1.1: unlock / save session id
|
||||
|
||||
export BW_SESSION="$(bw unlock --passwordenv TSYS_BW_PASSWORD_REACHABLECEO --raw)"
|
||||
|
||||
### Step 2: retrive a value into an environment variable
|
||||
|
||||
export DISCOURSE_APIKEY="$(bw get password APIKEY-discourse)"
|
||||
|
||||
}
|
||||
|
||||
post_dsr()
|
||||
|
||||
{
|
||||
|
||||
TODAY_DATE=$(date +%m-%d-%Y)
|
||||
|
||||
echo "Posting DSR..."
|
||||
|
||||
DISCOURSE_URL="https://community.turnsys.com" # e.g., https://forum.example.com
|
||||
API_KEY="$DISCOURSE_APIKEY" # Your API key
|
||||
API_USERNAME="reachableceo" # API username or admin account
|
||||
|
||||
# The category ID to post to (update to match your forum's categories)
|
||||
CATEGORY_ID=61
|
||||
|
||||
# The title for the post (generated here; customize as needed)
|
||||
TITLE="Daily Stakeholder Report - $TODAY_DATE"
|
||||
|
||||
# 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="../dsr-build-output/DSR-$TODAY_DATE.pdf"
|
||||
|
||||
# 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: $API_KEY" \
|
||||
-H "Api-Username: $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: $API_KEY" \
|
||||
-H "Api-Username: $API_USERNAME" \
|
||||
-d @- <<EOF
|
||||
{
|
||||
"title": "$TITLE",
|
||||
"raw": "$CONTENT",
|
||||
"category": $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
|
||||
|
||||
}
|
||||
|
||||
#Get discourse api key
|
||||
|
||||
secrets_manager
|
||||
|
||||
# - Create a new topic
|
||||
# - upload PDF to discourse
|
||||
# - attach uploaded PDF to the topic
|
||||
|
||||
post_dsr
|
Reference in New Issue
Block a user