.
This commit is contained in:
131
local/build/PublishStakeholderReport.sh
Normal file
131
local/build/PublishStakeholderReport.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
|
12
local/build/StakeholderProduct.yml
Normal file
12
local/build/StakeholderProduct.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
title: "{{ReportAuthor}} Daily Stakeholder Report - \today"
|
||||
titlepage: true
|
||||
titlepage-logo: "{{CandidateLogo}}"
|
||||
date: \today
|
||||
header-left: "\\hspace{1cm}"
|
||||
header-center: "\\leftmark"
|
||||
header-right: "Page \\thepage"
|
||||
footer-left: "{{ReportAuthor}}"
|
||||
footer-center: "{{AuthorTagline}}"
|
||||
footer-right: "[Pipeline Source code]({{SourceCode}})"
|
||||
urlcolor: {{URLCOLOR}}
|
||||
page-background: "{{PAGEBACKGROUND}}"
|
22
local/build/StakeholderProductVariables.env
Normal file
22
local/build/StakeholderProductVariables.env
Normal file
@@ -0,0 +1,22 @@
|
||||
###################################################
|
||||
# Modify these values to suit
|
||||
###################################################
|
||||
|
||||
#############################################################################
|
||||
#SET THIS NEXT VARIABLE OR NOTHING WILL WORK!!!!
|
||||
|
||||
export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/MarkdownResume-Pipeline-ClientExample/local"
|
||||
|
||||
#SET THE PREVIOUS VARIABLE OR NOTHING WILL WORK!!!!
|
||||
#############################################################################
|
||||
|
||||
##########################################
|
||||
# Layout/title page /formatting options
|
||||
##########################################
|
||||
|
||||
export ReportAuthor="First Middle Last"
|
||||
export AuthorTagline="Your.Tagline.Here."
|
||||
export AuthorLogo=""
|
||||
export SourceCode="https://git.knownelement.com/reachableceo/MarkdownResume-Pipeline"
|
||||
export URLCOLOR="blue"
|
||||
export PAGEBACKGROUND="./background3.pdf"
|
70
local/build/background5.pdf
Normal file
70
local/build/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
|
41
local/build/create-stakeholder-output-client.sh
Normal file
41
local/build/create-stakeholder-output-client.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is a demo script for the DSR-Pipeline-Server
|
||||
# This script creates PDF output from markdown input
|
||||
|
||||
|
||||
############################################
|
||||
#Edit this file to reflect your information
|
||||
############################################
|
||||
|
||||
source "./StakeholderProductVariables.env"
|
||||
|
||||
####################################################
|
||||
####################################################
|
||||
####################################################
|
||||
#DO NOT CHANGE ANYTHING BELOW THIS LINE
|
||||
####################################################
|
||||
####################################################
|
||||
####################################################
|
||||
|
||||
######################################################################################
|
||||
# Setup key variables that will be used by the build-pipeline-server-markdown.sh script
|
||||
######################################################################################
|
||||
|
||||
export MO_PATH="bash ../../vendor/git.knownelement.com/ExternalVendorCode/mo/mo"
|
||||
|
||||
export BUILD_TEMP_DIR="$PipelineClientWorkingDir/build-temp"
|
||||
export BUILD_OUTPUT_DIR="$PipelineClientWorkingDir/build-output"
|
||||
|
||||
export BUILDYAML_STAKEHOLDER_OUTPUT="$BUILD_TEMP_DIR/StakeholderOutput.yml"
|
||||
export StakeholderOutputMarkdownOutputFile="$BUILD_OUTPUT_DIR/StakeholderOutput.md"
|
||||
export StakeholderOutputPDFOutputFile="$BUILD_OUTPUT_DIR/StakeholderOutput.pdf"
|
||||
|
||||
|
||||
echo "Cleaning up from previous runs..."
|
||||
|
||||
rm $BUILDYAML_STAKEHOLDER_OUTPUT
|
||||
rm $StakeholderOutputMarkdownOutputFile
|
||||
rm $StakeholderOutputPDFOutputFile
|
||||
|
||||
bash ../../vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server/build/build-stakeholder-output-server.sh
|
Reference in New Issue
Block a user