Skip to content

Commit

Permalink
Add mdconvert.sh and devcontainer (#29)
Browse files Browse the repository at this point in the history
* Add change history limit. Closes #25.
* Use the pandoc/extra image to remove the need for build-container.
* Remove the PowerShell mdconvert script
* Add mdconvert.sh shell script and a devcontainer to simplify testing.
* Update issue template.
* Move pre-commit install to startup script.
* Update vscode settings.
  • Loading branch information
reijoh authored Nov 15, 2023
1 parent 65fc485 commit cb7ed3e
Show file tree
Hide file tree
Showing 24 changed files with 2,245 additions and 1,735 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"
},
"extensions": [
"bierner.markdown-preview-github-styles",
"catppuccin.catppuccin-vsc",
"catppuccin.catppuccin-vsc-icons",
"dbaeumer.vscode-eslint",
"DavidAnson.vscode-markdownlint",
"esbenp.prettier-vscode",
"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

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
touch ~/.zshrc
fi
if ! grep -q 'eval "$(starship init zsh)"' ~/.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
24 changes: 24 additions & 0 deletions .devcontainer/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/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 --get safe.directory)" != "*" ]; 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

pre-commit install
pre-commit autoupdate
4 changes: 0 additions & 4 deletions .dockerignore

This file was deleted.

10 changes: 1 addition & 9 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
- type: markdown
attributes:
value: |
Before opening a bug report, please search for the behaviour in the existing issues.
Before opening a bug report, please search for the behavior in the existing issues.
---
Expand All @@ -21,14 +21,6 @@ body:
placeholder: "macOS Big Sur 11.5.2"
validations:
required: true
- type: input
id: terraform
attributes:
label: Terraform Version
description: "Please provide the full Terraform version that you are using."
placeholder: "Terraform v1.2.3 on darwin_amd64"
validations:
required: true
- type: textarea
id: bug-description
attributes:
Expand Down
4 changes: 0 additions & 4 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
---
blank_issues_enabled: false
contact_links:
- name: Discuss on Teams
url: https://teams.microsoft.com/_?tenantId=67481c72-d897-4db4-a7fa-b96d76dfb545#/conversations/General?threadId=19:[email protected]&ctx=channel
about: Azure Consulting Channel
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
- type: markdown
attributes:
value: |
Before opening a feature report, please search for the behaviour in the existing issues.
Before opening a feature report, please search for the behavior in the existing issues.
---
Expand All @@ -34,4 +34,4 @@ body:
label: Additional information
description: Anything to give further context to the requested new feature.
validations:
required: true
required: true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/question.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
- type: markdown
attributes:
value: |
Before opening a question, please search for the behaviour in the existing issues.
Before opening a question, please search for the behavior in the existing issues.
---
Expand All @@ -20,4 +20,4 @@ body:
label: Your Query
description: A clear and concise query of what you want to ask.
validations:
required: true
required: true
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 cb7ed3e

Please sign in to comment.