Skip to content

Commit

Permalink
Build README.md via GitHub Action (#6)
Browse files Browse the repository at this point in the history
* Put README generation in GitHub Action
  • Loading branch information
maouw authored Oct 24, 2023
1 parent 6e66d52 commit 31c4caf
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 45 deletions.
41 changes: 0 additions & 41 deletions .build/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions .build/README.j2.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ssh [email protected]
After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter:

```bash
curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/{{ repo_name }}/main/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash
curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/{{github_repository}}/{{github_ref_name}}/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash
```

This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window.
Expand All @@ -88,7 +88,7 @@ This will download and install `hyakvnc` to your `~/.local/bin` directory and ad
In a terminal window connected to a login node, enter this command to clone the repository and navigate into the repository directory:

```bash
git clone {{ repo_url }} && cd hyakvnc
git clone https://github.com/{{github_repository}} && cd hyakvnc
```

Then, run the following command to install `hyakvnc`:
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/mkreadme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build documentation
"on":
push:

jobs:
build-readme:
runs-on: ubuntu-latest
name: Build README.md
permissions: write-all
steps:
- name: Install jinja-cli
run: |
python3 -m pip install jinja-cli
- name: Check out code for the container build
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if README.md has changed
id: readme-changed
run: |
if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/mkreadme.yml; then
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate configuration descriptions
run: |
pushd .build/
sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md
popd
- name: Generate usage descriptions
run: |
pushd .build/
for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md
popd
- name: Create and push README.md
run: |
pushd .build/
jinja -D github_repository "${{ github.repository }}" -D github_ref_name "${{ github.ref_name }}" README.j2.md | sed 's/^.*<!-- markdownlint-disable-file -->.*$//g' > ../README.md
popd
git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com"
git config --local user.name ${{ github.event.sender.login }}
git add README.md
git commit -am "Update README.md"
git push
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ ssh [email protected]
After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter:

```bash
curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/main/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash
curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/mkreadme-gha/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash
```

This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window.
Expand Down Expand Up @@ -245,7 +245,7 @@ Examples:
Usage: hyakvnc config [config options...]
Description:
Show the current configuration for hyakvnc, as set in the user configuration file at /home/altan/.hyakvnc/hyakvnc-config.env, in the current environment, or the default values set by hyakvnc.
Show the current configuration for hyakvnc, as set in the user configuration file at /home/runner/.hyakvnc/hyakvnc-config.env, in the current environment, or the default values set by hyakvnc.
Options:
-h, --help Show this help message and exit
Expand Down Expand Up @@ -291,6 +291,7 @@ When you set an environment variable, it is advisable to surround the value with
The following variables are available:

- HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`)
- HYAKVNC_CHECK_UPDATE_FREQUENCY: How often to check for updates in `[d]`ays or `[m]`inutes (default: `0` for every time. Use `1d` for daily, `10m` for every 10 minutes, etc. `-1` to disable.)
- HYAKVNC_CONFIG_FILE: Configuration file to use (default: `$HYAKVNC_DIR/hyakvnc-config.env`)
- HYAKVNC_LOG_FILE: Log file to use (default: `$HYAKVNC_DIR/hyakvnc.log`)
- HYAKVNC_LOG_LEVEL: Log level to use for interactive output (default: `INFO`)
Expand Down

0 comments on commit 31c4caf

Please sign in to comment.