mirror of
https://github.com/jbowdre/capsule.git
synced 2024-11-26 22:52:17 +00:00
Compare commits
No commits in common. "fa7f0b3157f51437fed865cd0f42aefb035e515d" and "bb60e9066200ae7241f09167a3f21504d2320791" have entirely different histories.
fa7f0b3157
...
bb60e90662
10 changed files with 0 additions and 177 deletions
23
.github/actions/markdown2gempost/Dockerfile
vendored
23
.github/actions/markdown2gempost/Dockerfile
vendored
|
@ -1,23 +0,0 @@
|
|||
FROM golang:1.22 AS go-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN git clone https://github.com/jbowdre/md2gmi.git
|
||||
|
||||
WORKDIR /app/md2gmi
|
||||
|
||||
RUN go mod download && CGO_ENABLED=0 GOOS=linux go build -o /md2gmi
|
||||
|
||||
FROM ubuntu:22.04 AS release
|
||||
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y uuid-runtime=2.37.2-4ubuntu3.4 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=go-builder /md2gmi /usr/local/bin/md2gmi
|
||||
COPY convert-dir.sh /usr/local/bin/convert-dir.sh
|
||||
RUN chmod +x /usr/local/bin/convert-dir.sh
|
||||
|
||||
WORKDIR /github/workspace
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/convert-dir.sh"]
|
19
.github/actions/markdown2gempost/action.yml
vendored
19
.github/actions/markdown2gempost/action.yml
vendored
|
@ -1,19 +0,0 @@
|
|||
name: 'Convert Markdown to Gempost'
|
||||
description: 'Convert Markdown posts to Gemtext with YAML sidecars for use with Gempost'
|
||||
inputs:
|
||||
input-dir:
|
||||
description: 'The directory containing markdown files'
|
||||
required: true
|
||||
output-dir:
|
||||
description: 'The directory to write gemini files to'
|
||||
required: true
|
||||
processed-dir:
|
||||
description: 'The directory to move processed markdown files to'
|
||||
required: true
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.input-dir }}
|
||||
- ${{ inputs.output-dir }}
|
||||
- ${{ inputs.processed-dir }}
|
52
.github/actions/markdown2gempost/convert-dir.sh
vendored
52
.github/actions/markdown2gempost/convert-dir.sh
vendored
|
@ -1,52 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Throw error if required paths are not provided
|
||||
if [ $# -ne 3 ]; then
|
||||
echo "Usage: $0 <input_dir> <output_dir> <processed_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# strip trailing slashes from input and output directories
|
||||
input_dir="${1%/}"
|
||||
output_dir="${2%/}"
|
||||
processed_dir="${3%/}"
|
||||
|
||||
# Find all .md files and check if the array is empty
|
||||
mapfile -t md_files < <(find "$input_dir" -type f -name "*.md")
|
||||
if [ ${#md_files[@]} -eq 0 ]; then
|
||||
echo "No Markdown files to process."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Iterate over .md files in input directory
|
||||
for file in "$input_dir"/*.md; do
|
||||
file=$(basename "$file")
|
||||
|
||||
# Extract frontmatter and dump it to YAML file
|
||||
echo "id: \"urn:uuid:$(uuidgen)\"" > "$output_dir/${file%.md}.yaml"
|
||||
awk '/^---$/{if(seen){exit}else{seen=1;next}} seen' "$input_dir/$file" >> "$output_dir/${file%.md}.yaml"
|
||||
echo "Wrote frontmatter file: $output_dir/${file%.md}.yaml"
|
||||
|
||||
# Check for HTML tags
|
||||
if grep -q '<[^>]*>' "$input_dir/$file"; then
|
||||
# Remove HTML tags, including those which may span multiple lines
|
||||
if awk -v RS='^$' -v ORS='' '{gsub(/<[^>]*>/, ""); print}' "$input_dir/$file" > "$input_dir/tmp.md"; then
|
||||
mv "$input_dir/tmp.md" "$input_dir/$file"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove empty/trailing spaces
|
||||
sed -i 's/[ \t]*$//' "$input_dir/$file"
|
||||
|
||||
# Convert Markdown to GMI
|
||||
/usr/local/bin/md2gmi -i "$input_dir/$file" -o "$output_dir/${file%.md}.gmi"
|
||||
# Remove first line (and blank lines which follow) from output file (gempost will render the title)
|
||||
if awk 'NR == 1 {next} NF == 0 && !p {next} {p=1; print}' "$output_dir/${file%.md}.gmi" > "$output_dir/tmp.gmi"; then
|
||||
mv "$output_dir/tmp.gmi" "$output_dir/${file%.md}.gmi"
|
||||
fi
|
||||
|
||||
echo "Wrote gemtext file: $output_dir/${file%.md}.gmi"
|
||||
|
||||
# Move original Markdown file to processed directory
|
||||
mv "$input_dir/$file" "$processed_dir/$file"
|
||||
done
|
35
.github/workflows/markdown2gempost.yml
vendored
35
.github/workflows/markdown2gempost.yml
vendored
|
@ -1,35 +0,0 @@
|
|||
name: "Markdown to Gempost"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'markdown/**'
|
||||
|
||||
concurrency:
|
||||
group: md2gmi
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
md2gmi:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ secrets.MY_GH_TOKEN }}
|
||||
- uses: ./.github/actions/markdown2gempost
|
||||
with:
|
||||
input-dir: 'markdown/incoming'
|
||||
output-dir: 'gemlog'
|
||||
processed-dir: 'markdown'
|
||||
- uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
commit_message: 'convert Markdown post to Gempost'
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
This is a quick post to see if this absolute nonsense[1] I have cobbled together actually works.
|
||||
|
||||
=> https://github.com/jbowdre/capsule/blob/main/.github/workflows/markdown2gempost.yml 1: absolute nonsense
|
||||
|
||||
If it works:
|
||||
|
||||
- EchoFeed[1] will see this post in my Scribbles RSS feed, and relay it to my GitHub repo as a Markdown file.
|
||||
=> https://echofeed.app/ 1: EchoFeed
|
||||
|
||||
- My new GitHub Actions workflow will see the new Markdown file, use a script and md2gmi[1] in a Docker container to convert the Markdown to Gemtext along with a YAML metadata sidecar for gempost, and store the results in the repo.
|
||||
- The existing workflow will see the new gemtext post and use gempost[2] to (re)build the site, and then deploy it to my virtual server where it will be made available within Geminispace.
|
||||
|
||||
=> https://github.com/n0x1m/md2gmi 1: md2gmi
|
||||
=> https://github.com/justlark/gempost 2: gempost
|
||||
|
||||
I really hope this works.
|
||||
|
|
@ -1 +0,0 @@
|
|||
id: "urn:uuid:7826c3b3-fa43-4c55-9b7e-6b49879180ff"
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
title: "Echofeed Integration Test"
|
||||
published: "2024-04-13T22:11:06.000000Z"
|
||||
updated: "2024-04-13T22:11:06.000000Z"
|
||||
---
|
||||
|
||||
This is a quick post to see if this [absolute nonsense](https://github.com/jbowdre/capsule/blob/main/.github/workflows/markdown2gempost.yml) I have cobbled together actually works.
|
||||
|
||||
If it works:
|
||||
|
||||
- [EchoFeed](https://echofeed.app/) will see this post in my Scribbles RSS feed, and relay it to my GitHub repo as a Markdown file.
|
||||
- My new GitHub Actions workflow will see the new Markdown file, use a script and [md2gmi](https://github.com/n0x1m/md2gmi) in a Docker container to convert the Markdown to Gemtext along with a YAML metadata sidecar for gempost, and store the results in the repo.
|
||||
- The existing workflow will see the new gemtext post and use [gempost](https://github.com/justlark/gempost) to (re)build the site, and then deploy it to my virtual server where it will be made available within Geminispace.
|
||||
|
||||
I really hope this works.
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
title: "Echofeed Integration Test"
|
||||
published: "2024-04-13T23:01:36.000000Z"
|
||||
updated: "2024-04-13T23:01:36.000000Z"
|
||||
---
|
||||
|
||||
This is a quick post to see if this [absolute nonsense](https://github.com/jbowdre/capsule/blob/main/.github/workflows/markdown2gempost.yml) I have cobbled together actually works.
|
||||
|
||||
If it works:
|
||||
|
||||
- [EchoFeed](https://echofeed.app/) will see this post in my Scribbles RSS feed, and relay it to my GitHub repo as a Markdown file.
|
||||
- My new GitHub Actions workflow will see the new Markdown file, use a script and [md2gmi](https://github.com/n0x1m/md2gmi) in a Docker container to convert the Markdown to Gemtext along with a YAML metadata sidecar for gempost, and store the results in the repo.
|
||||
- The existing workflow will see the new gemtext post and use [gempost](https://github.com/justlark/gempost) to (re)build the site, and then deploy it to my virtual server where it will be made available within Geminispace.
|
||||
|
||||
I really hope this works.
|
Loading…
Reference in a new issue