Compare commits

...

20 Commits

Author SHA1 Message Date
5096d201b0 pipeline changes, preparing to dockerize etc 2025-07-11 22:01:03 -05:00
512accf6d6 made readme reflect new reduced scope 2024-12-18 11:24:18 -06:00
d7c2171265 maintenace 2024-12-18 08:39:34 -06:00
c4bc5f8e94 . 2024-12-15 16:50:54 -06:00
f91f8290cd Update "DSR-Pipeline-Server" from "https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git@main"
git-vendor-name: DSR-Pipeline-Server
git-vendor-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-vendor-repository: https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git
git-vendor-ref: main
2024-12-15 16:47:51 -06:00
761a9b12f7 Squashed 'vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server/' changes from 284d9ba..82b1c41
82b1c41 .

git-subtree-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-subtree-split: 82b1c41c6ffaba48abcb10b822397c62f94a7645
2024-12-15 16:47:51 -06:00
d6c98f0c22 . 2024-12-15 16:47:33 -06:00
f0a6dc9813 Squashed 'vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server/' changes from 6111944..284d9ba
284d9ba variables...

git-subtree-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-subtree-split: 284d9ba86e6d0ae4c7c1087556702ba262f57971
2024-12-15 10:19:50 -06:00
4fd5750111 Update "DSR-Pipeline-Server" from "https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git@main"
git-vendor-name: DSR-Pipeline-Server
git-vendor-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-vendor-repository: https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git
git-vendor-ref: main
2024-12-15 10:19:50 -06:00
3ad72ff964 . 2024-12-15 10:19:44 -06:00
4f6ced27de . 2024-12-15 00:09:15 -06:00
b6504955b5 . 2024-12-15 00:07:23 -06:00
bbce36ab4f . 2024-12-14 23:56:02 -06:00
e50770c4ef 0.1 . succesfull test run. 2024-12-14 23:51:24 -06:00
a31d481243 0.1 . succesfull test run. 2024-12-14 23:51:16 -06:00
e4ad4dfd47 Squashed 'vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server/' changes from 6a9e091..6111944
6111944 .

git-subtree-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-subtree-split: 6111944163473b2b503d8683628f83ec49365137
2024-12-14 23:26:49 -06:00
9d6d0ee899 Update "DSR-Pipeline-Server" from "https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git@main"
git-vendor-name: DSR-Pipeline-Server
git-vendor-dir: vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server
git-vendor-repository: https://git.knownelement.com/reachableceo/DSR-Pipeline-Server.git
git-vendor-ref: main
2024-12-14 23:26:49 -06:00
3867abef32 . 2024-12-14 23:24:04 -06:00
10d8ef5b9c . 2024-12-14 23:22:09 -06:00
5ddf70eec5 . 2024-12-14 23:22:04 -06:00
18 changed files with 198 additions and 216 deletions

7
.gitignore vendored
View File

@@ -1,2 +1,5 @@
dsr-build-temp/
dsr-build-output/
local/build-temp/*.md
local/build-temp/*.yml
local/build-output/*.md
local/build-output/*.pdf

View File

@@ -1,2 +1,5 @@
# 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.

View File

@@ -0,0 +1,45 @@
###################################################
# Modify these values to suit
###################################################
#############################################################################
#SET THESE VARIABLES OR NOTHING WILL WORK!!!!
export PipelineClientWorkingDir="D:/tsys/@ReachableCEO/DSR-Pipeline-ClientExample/local"
export StakeholderOutputMarkdownInputFile="$1"
#############################################################################
##########################################
# Layout/title page /formatting options
##########################################
export ReportAuthor="First Middle Last"
export AuthorTagline="Your.Tagline.Here."
export AuthorLogo=""
export SourceCode="https://git.knownelement.com/reachableceo/DSR-Pipeline-ClientExample"
export URLCOLOR="blue"
export PAGEBACKGROUND="$PipelineClientWorkingDir/build/background5.pdf"
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=""

View File

@@ -0,0 +1 @@
ignore

View File

@@ -0,0 +1 @@
ignore

View File

@@ -1,4 +1,4 @@
title: "{{ReportAuthor}} Daily Stakeholder Report - \today"
title: "{{ReportAuthor}} Daily Stakeholder Report : \today"
titlepage: true
titlepage-logo: "{{CandidateLogo}}"
date: \today

View File

@@ -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

View File

@@ -1,22 +0,0 @@
###################################################
# 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"

View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -euo pipefail
# This is a demo script for the DSR-Pipeline-Server
# This script creates PDF output from markdown input
###############@##################################
#Edit the below file to reflect your information
##################################################
source "../StakeholderOutputVariables.env"
####################################################
#DO NOT CHANGE ANYTHING BELOW THIS LINE
####################################################
export MO_PATH="bash ../../vendor/git.knownelement.com/ExternalVendorCode/mo/mo"
echo "Cleaning up from previous runs..."
rm $BUILDYAML_STAKEHOLDER_OUTPUT || true
rm $StakeholderOutputMarkdownOutputFile || true
rm $StakeholderOutputPDFOutputFile || true
echo "Combining markdown files into single input file for pandoc..."
cat $StakeholderOutputMarkdownInputFile > $StakeholderOutputMarkdownOutputFile
#Call the build stakeholder output microservice
echo "Calling the build stakeholder output microservice..."
bash ../../vendor/git.knownelement.com/reachableceo/DSR-Pipeline-Server/build/build-stakeholder-output-server.sh

View File

@@ -1,41 +0,0 @@
#!/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

View File

@@ -0,0 +1,6 @@
# Demo Report
# Time log
1:00:
- stuff

View File

@@ -0,0 +1,83 @@
#!/bin/bash
# Script to query Gitea API for a user's activity on a specific date
########################################################################################################
#Obtain gitea api key from bitwarden
########################################################################################################
####################################
## Step 0: Set to use tsys server
####################################
bw logout
echo "Setting cli to use tsys bitwarden 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
echo "Sourcing clientid/apikey data..."
source D:/tsys/secrets/bitwarden/data/apikey-bitwarden-reachableceo
### Login to vault using apikey...
echo "Logging in..."
bw login --apikey $BW_CLIENTID $BW_CLIENTSECRET
### Step 1.1: unlock / save session id
echo "Unlocking..."
export BW_SESSION="$(bw unlock --passwordenv TSYS_BW_PASSWORD_REACHABLECEO --raw)"
### Step 2: retrive a value into an environment variable
export GITEA_APIKEY="$(bw get password APIKEY-Gitea)"
########################################################################################################
# Accrss gitea data
########################################################################################################
# Script to query Gitea API for a user's activity on a specific date
# Usage: ./get_gitea_user_activity.sh <username> <date> [GITEA_URL] [TOKEN]
# Set username, date, and default Gitea URL
USERNAME="${1:-reachableceo}" # Default to "reachableceo" if not provided
DATE="${2:-$(date +%Y-%m-%d)}" # Default to today's date if not provided
GITEA_URL="${3:-https://git.knownelement.com}" # Default Gitea URL if not provided
TOKEN="${GITEA_APIKEY}" # Use APIKEY-GItea or passed argument
# API Endpoint for user activities
API_ENDPOINT="$GITEA_URL/api/v1/users/$USERNAME/timeline"
# Make the API call
if [ -n "$TOKEN" ]; then
# If token is provided, use it in the Authorization header
RESPONSE=$(curl -s -H "Authorization: token $TOKEN" "$API_ENDPOINT")
else
# If no token is provided, make an unauthenticated request
RESPONSE=$(curl -s "$API_ENDPOINT")
fi
# Check for API errors
if [[ "$RESPONSE" == "Not found" || -z "$RESPONSE" ]]; then
echo "Error: User '$USERNAME' not found, or endpoint is incorrect."
exit 1
fi
# Validate JSON response
if ! echo "$RESPONSE" | jq empty >/dev/null 2>&1; then
echo "Error: Invalid JSON response from Gitea API."
echo "Response: $RESPONSE"
exit 1
fi
# Filter the activity by date using jq
echo "$RESPONSE" | jq --arg date "$DATE" '[.[] | select(.created_at | startswith($date))]'

View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -euo pipefail
# Expand variables into rendered YAML files. These will be used by pandoc to format the output artifacts
$MO_PATH $YamlInputTemplateFileStakeholderOutput > $BUILDYAML_STAKEHOLDER_OUTPUT
echo "Creating stakeholder report..."
pandoc \
"$StakeholderOutputMarkdownOutputFile" \
--template $PANDOC_TEMPLATE \
--metadata-file="$BUILDYAML_STAKEHOLDER_OUTPUT" \
--from markdown \
--to=pdf \
--output $StakeholderOutputPDFOutputFile

View File

@@ -1,13 +0,0 @@
#!/bin/bash
$MO_PATH $PipelineClientWorkingDir/build/StakeholderOutput.yml > $BUILDYAML_STAKEHOLDER_OUTPUT
echo "Creating stakeholder report..."
pandoc \
"$StakeholderOutputMarkdownOutputFile" \
--template $PANDOC_TEMPLATE \
--metadata-file="$BUILDYAML_STAKEHOLDER_OUTPUT" \
--from markdown \
--to=pdf \
--output $StakeholderOutputPDFOutputFile

View File

@@ -12,8 +12,8 @@ fi
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" \
-H "Api-Key: $DISCOURSE_API_KEY" \
-H "Api-Username: $DISCOURSE_API_USERNAME" \
-F "file=@$FILE_PATH;type=application/pdf" \
-F "type=composer")
@@ -38,13 +38,13 @@ CONTENT="$CONTENT\n\n[Download todays report in PDF format]($short_url)"
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" \
-H "Api-Key: $DISCOURSE_API_KEY" \
-H "Api-Username: $DISCOURSE_API_USERNAME" \
-d @- <<EOF
{
"title": "$TITLE",
"title": "$DISCOURSE_POST_TITLE",
"raw": "$CONTENT",
"category": $CATEGORY_ID
"category": $DISCOURSE_CATEGORY_ID
}
EOF
)