Skip to content

Commit

Permalink
Add mdconvert.sh and devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
reijoh committed Nov 7, 2023
1 parent 65fc485 commit 012e9d0
Show file tree
Hide file tree
Showing 20 changed files with 2,238 additions and 1,725 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "markdown2pdf",
"image": "pandoc/extra:edge-alpine",
"onCreateCommand": ".devcontainer/setup.sh",
"postStartCommand": ".devcontainer/startup.sh",
"overrideCommand": true,
"customizations": {
"vscode": {
"settings": {
"security.workspace.trust.untrustedFiles": "open",
"terminal.integrated.defaultProfile.linux": "zsh"
},
"extensions": [
"bierner.markdown-preview-github-styles",
"catppuccin.catppuccin-vsc",
"catppuccin.catppuccin-vsc-icons",
"dbaeumer.vscode-eslint",
"DavidAnson.vscode-markdownlint",
"GitHub.vscode-pull-request-github",
"streetsidesoftware.code-spell-checker",
"yzhang.markdown-all-in-one"
]
}
}
}
37 changes: 37 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env sh
if [ -d "/var/run/docker.sock" ]; then
# Grant access to the docker socket
sudo chmod 666 /var/run/docker.sock
fi

if ! [ -d ~/.ssh ]; then
if [ -d /tmp/.ssh-localhost ]; then
command mkdir -p -- ~/.ssh
sudo cp -R /tmp/.ssh-localhost/* ~/.ssh
sudo chown -R $(whoami):$(whoami) ~ || true ?>/dev/null
sudo chmod 400 ~/.ssh/*
fi
fi

apk add --no-cache git jq librsvg font-noto-cjk zsh bash starship
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community font-carlito font-fira-code-nerd shellcheck

pip install pre-commit

tlmgr option -- autobackup -1
tlmgr install lastpage

pre-commit install
pre-commit autoupdate

if [ -f ~/.gitconfig ]; then
rm ~/.gitconfig
fi

if ! [ -d ~/.config ]; then
command mkdir -p -- ~/.config
fi
/bin/cp -f .devcontainer/starship.toml ~/.config/starship.toml
if [ ! -f ~/.zshrc ]; then
echo 'eval "$(starship init zsh)"' >>~/.zshrc
fi
35 changes: 35 additions & 0 deletions .devcontainer/starship.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
command_timeout = 500
format = "$directory$git_branch$time$cmd_duration$character"

[character]
success_symbol = "[➜](bold green)"
error_symbol = "[✖](bold red)"

[cmd_duration]
min_time = 500
format = "took [$duration](bold yellow)"

[directory]
read_only = ""
truncation_length = 3
truncation_symbol = "~/"

[git_branch]
symbol = ""
style = "bold #e8ec00 inverted"
format = "on [$symbol$branch ]($style) "

[git_commit]
disabled = true

[git_state]
disabled = true

[git_status]
disabled = true

[line_break]
disabled = true

[package]
disabled = true
21 changes: 21 additions & 0 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env sh
if [ "${CODESPACES}" = "true" ]; then
# Remove the default credential helper
sudo sed -i -E 's/helper =.*//' /etc/gitconfig

# Add one that just uses secrets available in the Codespace
git config --global credential.helper '!f() { sleep 1; echo "username=${GITHUB_USER}"; echo "password=${GH_TOKEN}"; }; f'
fi

if [ ! $(git config --global --get safe.directory | grep "*" 2>&1) ]; then
git config --global --add safe.directory "*"
fi
if [ "$(git config pull.rebase)" != "false" ]; then
git config --global pull.rebase false
fi
if [ "$(git config user.name)" = "" ]; then
echo "Warning: git user.name is not configured"
fi
if [ "$(git config user.email)" = "" ]; then
echo "Warning: git user.email is not configured"
fi
4 changes: 0 additions & 4 deletions .dockerignore

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/build-container.yml

This file was deleted.

48 changes: 26 additions & 22 deletions .github/workflows/convert-markdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
Project:
required: false
type: string
default: ''
default: ""
Folder:
required: false
type: string
Expand All @@ -28,6 +28,14 @@ on:
required: false
type: string
default: document.order
HistoryFile:
required: false
type: string
default: ""
ReplaceFile:
required: false
type: string
default: ""
OutFile:
required: false
type: string
Expand All @@ -40,6 +48,10 @@ on:
required: false
type: string
default: Initial draft
LimitVersionHistory:
required: false
type: number
default: 15
ForceDefault:
required: false
type: boolean
Expand All @@ -54,34 +66,26 @@ jobs:
name: Convert Markdown
runs-on: ubuntu-latest
container:
image: innofactoriac.azurecr.io/mdconvert:latest
credentials:
username: fb505ffb-02a5-428c-9030-9d0809ba322d
password: ${{ secrets.INNOFACTORIAC_MDCONVERT_ACRPULL_CLIENT_SECRET }}
image: pandoc/extra:edge-alpine
options: --entrypoint=sh
steps:
- name: Clone repository for building
uses: actions/checkout@v3
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
# with:
# ## limits ssh access and adds the ssh public key for the user which triggered the workflow
# limit-access-to-actor: false

# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# limit-access-to-actor: true
- name: Install requirements
shell: sh
run: |
apk add --no-cache git jq librsvg font-noto-cjk
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community font-carlito
tlmgr install lastpage
- name: Build PDF
shell: pwsh
shell: sh
run: |
$Global:ProgressPreference = 'SilentlyContinue';
$forceDefault = '${{ inputs.ForceDefault }}' -eq 'true';
& git config --global safe.directory '*';
& /usr/local/mdconvert/mdconvert.ps1 -Title '${{ inputs.Title }}' -Subtitle '${{ inputs.Subtitle }}' -Project '${{ inputs.Project }}' -Folder '${{ inputs.Folder }}' -Template '${{ inputs.Template }}' -OrderFile '${{ inputs.OrderFile }}' -OutFile '${{ inputs.OutFile }}' -DefaultAuthor '${{ inputs.DefaultAuthor }}' -DefaultDescription '${{ inputs.DefaultDescription }}' -ForceDefault:$forceDefault
git config --global --add safe.directory '*'
tools/mdconvert.sh -a '${{ inputs.DefaultAuthor }}' -d '${{ inputs.DefaultDescription }}' -f '${{ inputs.Folder }}' -force '${{ inputs.ForceDefault }}' -h '${{ inputs.HistoryFile }}' -l ${{ inputs.LimitVersionHistory }} -o '${{ inputs.OrderFile }}' -out '${{ inputs.OutFile }}' -p '${{ inputs.Project }}' -r '${{ inputs.ReplaceFile }}' -s '${{ inputs.Subtitle }}' -t '${{ inputs.Title }}' --template '${{ inputs.Template }}'
- name: Publish PDF
uses: actions/upload-artifact@v3
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/pull-labels-changeset_size.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
---
name: "📁 Changeset Size"
name: "📁 Changeset size"

on: # yamllint disable-line rule:truthy
on:
pull_request:
branches:
- main

jobs:
labeler:
name: Pull Changeset Size
name: "Changeset size"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:

- name: Labeler
- name: "Labeler"
uses: actions/labeler@v4
with:
configuration-path: .github/labeler.yml
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Label Size
uses: pascalgn/size-label-action@v0.4.3
- name: "Label size"
uses: pascalgn/size-label-action@v0.5.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
Loading

0 comments on commit 012e9d0

Please sign in to comment.