Compare commits

...

8 Commits

Author SHA1 Message Date
673afd932c made readme reflect new reduced scope 2024-12-18 11:22:55 -06:00
9455b220fd maintenace 2024-12-18 08:39:05 -06:00
be2f756048 removed some debugging bits 2024-12-16 12:51:57 -06:00
ca6f7001c1 . 2024-12-15 17:25:43 -06:00
4cd6c38e93 . 2024-12-15 17:12:12 -06:00
82b1c41c6f . 2024-12-15 16:47:19 -06:00
284d9ba86e variables... 2024-12-15 10:19:20 -06:00
6111944163 . 2024-12-14 23:26:06 -06:00
5 changed files with 24 additions and 119 deletions

2
.gitignore vendored
View File

@@ -1,2 +0,0 @@
dsr-build-temp/
dsr-build-output/

View File

@@ -1,47 +1,8 @@
# DailyStakeholderReport-Pipeline
- [DailyStakeholderReport-Pipeline](#dailystakeholderreport-pipeline)
- [Introduction](#introduction)
- [Scripts](#scripts)
- [Start a new day](#start-a-new-day)
- [Create a new (blank) DSR](#create-a-new-blank-dsr)
- [Populate the new DSR with objectives for the day](#populate-the-new-dsr-with-objectives-for-the-day)
- [End the day](#end-the-day)
- [Collating and Publishing the report](#collating-and-publishing-the-report)
- [Gathering data for the report](#gathering-data-for-the-report)
This repo is very similiar to my other markdown/PDF micro servcies.
## Introduction
It...
I publish a daily stakeholder report to the TSYS Group discourse every day. Up until 11/29 I was performing the publishing step manually. On 11/29 I automated the pdf creation and publishing to discourse procedure.
I also begin work on automated gathering of data going into the new version of the report that is in development.
## Scripts
### Start a new day
Start a new day. See the script: **endstops/start-day.sh**
#### Create a new (blank) DSR
See the script: **dsr-joplin-create/dsr-new.sh**
#### Populate the new DSR with objectives for the day
See the script: **dsr-joplin-create/dsr-populate-objectives.sh**
### End the day
End the day. See the script: **endstops/end-day.sh**
#### Collating and Publishing the report
Publishing the report involves three steps:
1. Exporting the markdown from Joplin (and any attachments (i often take screenshots throughout the day)) I am still doing this manually due to having issues installing the Joplin CLI.
2. Creating a (formatted/styled) PDF from the exported markdown/attachments. See the script: **dsr-publish/create-dsr-pdf.sh**.
3. Uploading the PDF to discourse and creating a new topic in the appropriate category. See the script: **dsr-publish/publish-dsr.sh**
#### Gathering data for the report
- Renders a yaml template using values passed in by the calling microservice.
- Uses pandoc with the rendered yaml template to create a PDF.

View File

@@ -0,0 +1,20 @@
#!/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..."
cd "$(dirname $StakeholderOutputMarkdownInputFile)"
pandoc \
"$StakeholderOutputMarkdownOutputFile" \
--template $PANDOC_TEMPLATE \
--metadata-file="$BUILDYAML_STAKEHOLDER_OUTPUT" \
--from markdown \
--to=pdf \
--output $StakeholderOutputPDFOutputFile
cd -

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

@@ -1,61 +0,0 @@
#!/bin/bash
echo "Posting Stakeholder Report..."
# 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" | 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