Compare commits
10 Commits
4f6ced27de
...
main
Author | SHA1 | Date | |
---|---|---|---|
5096d201b0 | |||
512accf6d6 | |||
d7c2171265 | |||
c4bc5f8e94 | |||
f91f8290cd | |||
761a9b12f7 | |||
d6c98f0c22 | |||
f0a6dc9813 | |||
4fd5750111 | |||
3ad72ff964 |
@@ -1,2 +1,5 @@
|
|||||||
# DSR-Pipeline-ClientExample
|
# DSR-Pipeline-ClientExample
|
||||||
|
|
||||||
|
This repo is very similar to my other markdown/PDF client microservices.
|
||||||
|
|
||||||
|
It's an example of a simple daily stakeholder report rendering process.
|
||||||
|
@@ -3,13 +3,14 @@
|
|||||||
###################################################
|
###################################################
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
#SET THIS NEXT VARIABLE OR NOTHING WILL WORK!!!!
|
#SET THESE VARIABLES OR NOTHING WILL WORK!!!!
|
||||||
|
|
||||||
export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/DSR-Pipeline-ClientExample/local"
|
export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/DSR-Pipeline-ClientExample/local"
|
||||||
|
export StakeholderOutputMarkdownInputFile="$1"
|
||||||
|
|
||||||
#SET THE PREVIOUS VARIABLE OR NOTHING WILL WORK!!!!
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# Layout/title page /formatting options
|
# Layout/title page /formatting options
|
||||||
##########################################
|
##########################################
|
||||||
@@ -17,7 +18,28 @@ export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/DSR-Pipeline-ClientExampl
|
|||||||
export ReportAuthor="First Middle Last"
|
export ReportAuthor="First Middle Last"
|
||||||
export AuthorTagline="Your.Tagline.Here."
|
export AuthorTagline="Your.Tagline.Here."
|
||||||
export AuthorLogo=""
|
export AuthorLogo=""
|
||||||
export SourceCode="https://git.knownelement.com/reachableceo/MarkdownResume-Pipeline"
|
export SourceCode="https://git.knownelement.com/reachableceo/DSR-Pipeline-ClientExample"
|
||||||
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"
|
||||||
|
export YamlInputTemplateFileStakeholderOutput="$PipelineClientWorkingDir/build/BuildTemplate-StakeholderOutput.yml"
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# Output Artifact variables
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
|
###################################################################
|
||||||
|
# Publish variables
|
||||||
|
###################################################################
|
||||||
|
|
||||||
|
export DISCOURSE_URL=""
|
||||||
|
export DISCOURSE_API_USERNAME=""
|
||||||
|
export DISCOURSE_CATEGORY_ID=""
|
||||||
|
export DISCOURSE_POST_TITLE=""
|
@@ -1,131 +0,0 @@
|
|||||||
#!/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
|
|
@@ -5,36 +5,18 @@ set -euo pipefail
|
|||||||
# This is a demo script for the DSR-Pipeline-Server
|
# This is a demo script for the DSR-Pipeline-Server
|
||||||
# This script creates PDF output from markdown input
|
# This script creates PDF output from markdown input
|
||||||
|
|
||||||
|
|
||||||
###############@##################################
|
###############@##################################
|
||||||
#Edit the below file to reflect your information
|
#Edit the below file to reflect your information
|
||||||
##################################################
|
##################################################
|
||||||
|
|
||||||
source "../StakeholderOutputVariables.env"
|
source "../StakeholderOutputVariables.env"
|
||||||
|
|
||||||
####################################################
|
|
||||||
####################################################
|
|
||||||
####################################################
|
####################################################
|
||||||
#DO NOT CHANGE ANYTHING BELOW THIS LINE
|
#DO NOT CHANGE ANYTHING BELOW THIS LINE
|
||||||
####################################################
|
####################################################
|
||||||
####################################################
|
|
||||||
####################################################
|
|
||||||
|
|
||||||
############################################################################################
|
|
||||||
# Setup key variables that will be used by the create-stakeholder-output-server.sh script
|
|
||||||
############################################################################################
|
|
||||||
|
|
||||||
export MO_PATH="bash ../../vendor/git.knownelement.com/ExternalVendorCode/mo/mo"
|
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"
|
|
||||||
|
|
||||||
export StakeholderOutputMarkdownInputFile="$1"
|
|
||||||
|
|
||||||
echo "Cleaning up from previous runs..."
|
echo "Cleaning up from previous runs..."
|
||||||
|
|
||||||
rm $BUILDYAML_STAKEHOLDER_OUTPUT || true
|
rm $BUILDYAML_STAKEHOLDER_OUTPUT || true
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Expand variables into rendered YAML files. These will be used by pandoc to format the output artifacts
|
# Expand variables into rendered YAML files. These will be used by pandoc to format the output artifacts
|
||||||
$MO_PATH $PipelineClientWorkingDir/build/BuildTemplate-StakeholderOutput.yml > $BUILDYAML_STAKEHOLDER_OUTPUT
|
$MO_PATH $YamlInputTemplateFileStakeholderOutput > $BUILDYAML_STAKEHOLDER_OUTPUT
|
||||||
|
|
||||||
echo "Creating stakeholder report..."
|
echo "Creating stakeholder report..."
|
||||||
|
|
||||||
|
@@ -12,8 +12,8 @@ fi
|
|||||||
echo "Uploading file..."
|
echo "Uploading file..."
|
||||||
upload_response=$(curl -s -X POST "$DISCOURSE_URL/uploads.json" \
|
upload_response=$(curl -s -X POST "$DISCOURSE_URL/uploads.json" \
|
||||||
-H "Content-Type: multipart/form-data" \
|
-H "Content-Type: multipart/form-data" \
|
||||||
-H "Api-Key: $API_KEY" \
|
-H "Api-Key: $DISCOURSE_API_KEY" \
|
||||||
-H "Api-Username: $API_USERNAME" \
|
-H "Api-Username: $DISCOURSE_API_USERNAME" \
|
||||||
-F "file=@$FILE_PATH;type=application/pdf" \
|
-F "file=@$FILE_PATH;type=application/pdf" \
|
||||||
-F "type=composer")
|
-F "type=composer")
|
||||||
|
|
||||||
@@ -38,13 +38,13 @@ CONTENT="$CONTENT\n\n[Download todays report in PDF format]($short_url)"
|
|||||||
echo "Creating new topic..."
|
echo "Creating new topic..."
|
||||||
post_response=$(curl -s -X POST "$DISCOURSE_URL/posts.json" \
|
post_response=$(curl -s -X POST "$DISCOURSE_URL/posts.json" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Api-Key: $API_KEY" \
|
-H "Api-Key: $DISCOURSE_API_KEY" \
|
||||||
-H "Api-Username: $API_USERNAME" \
|
-H "Api-Username: $DISCOURSE_API_USERNAME" \
|
||||||
-d @- <<EOF
|
-d @- <<EOF
|
||||||
{
|
{
|
||||||
"title": "$TITLE",
|
"title": "$DISCOURSE_POST_TITLE",
|
||||||
"raw": "$CONTENT",
|
"raw": "$CONTENT",
|
||||||
"category": $CATEGORY_ID
|
"category": $DISCOURSE_CATEGORY_ID
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user