Compare commits
13 Commits
v0.1
...
6a9e091270
Author | SHA1 | Date | |
---|---|---|---|
6a9e091270 | |||
bfcccb562e | |||
840d1c8b9e | |||
c9f70602ba | |||
40e1cbc498 | |||
65824280a7 | |||
d4899ee823 | |||
7715928bae | |||
2e1759af8a | |||
cbc1881e55 | |||
d011825524 | |||
25fe5cfd73 | |||
a57254f8aa |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
dsr-build-temp/
|
||||||
|
dsr-build-output/
|
46
README.md
46
README.md
@@ -1,3 +1,47 @@
|
|||||||
# DailyStakeholderReport-Pipeline
|
# DailyStakeholderReport-Pipeline
|
||||||
|
|
||||||
Scripts I use to help gather data and publish my daily stakeholder report.
|
- [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)
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
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
|
13
build/create-stakeholder-output-server.sh
Normal file
13
build/create-stakeholder-output-server.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/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
|
61
build/publish-stakeholder-output-server.sh
Normal file
61
build/publish-stakeholder-output-server.sh
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
#!/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
|
@@ -1,152 +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)"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
generate_dsr()
|
|
||||||
{
|
|
||||||
|
|
||||||
echo "Creating PDF of DSR from markdown input via pandoc..."
|
|
||||||
|
|
||||||
INPUT_FILE="./DSR-$(date +%m-%d-%Y).md"
|
|
||||||
OUTPUT_FILE="./DSR-$(date +%m-%d-%Y).pdf"
|
|
||||||
METADATA_FILE="daily-stakeholder-report.yml"
|
|
||||||
TEMPLATE="eisvogel"
|
|
||||||
|
|
||||||
pandoc \
|
|
||||||
$INPUT_FILE \
|
|
||||||
--template $TEMPLATE \
|
|
||||||
--metadata-file=$METADATA_FILE \
|
|
||||||
--from markdown \
|
|
||||||
--to=pdf \
|
|
||||||
--output $OUTPUT_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
post_dsr()
|
|
||||||
|
|
||||||
{
|
|
||||||
echo "Posting DSR..."
|
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Replace these with your Discourse instance details
|
|
||||||
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 - $(date +'%m-%d-%Y')"
|
|
||||||
|
|
||||||
# The content of the post
|
|
||||||
CONTENT="Please see the attached PDF for today's report."
|
|
||||||
|
|
||||||
# The file to upload (from the second argument or auto-generated based on date)
|
|
||||||
FILE_PATH="./DSR-"$(date +%m-%d-%Y)".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 the PDF]($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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#Create PDF from joplin exported markdown
|
|
||||||
generate_dsr
|
|
||||||
|
|
||||||
#Get discourse api key
|
|
||||||
secrets_manager
|
|
||||||
|
|
||||||
#Create a new topic and upload/attach PDF to the topic
|
|
||||||
post_dsr
|
|
@@ -1,83 +0,0 @@
|
|||||||
#!/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))]'
|
|
Reference in New Issue
Block a user