build: replace justfile with run
This commit is contained in:
parent
44fea3ce7c
commit
e61b2bff17
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -15,15 +15,13 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||
- uses: extractions/setup-just@95b912dc5d3ed106a72907f2f9b91e76d60bdb76 # 1.5.0
|
||||
|
||||
- uses: cachix/install-nix-action@6ed004b9ccb68dbc28e7c85bee15fa93dbd214ac # v22
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixos-unstable
|
||||
|
||||
- run: |
|
||||
nix develop --command yarn
|
||||
nix develop --command yarn build
|
||||
./run ci:build
|
||||
|
||||
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
||||
with:
|
||||
|
@ -37,8 +35,6 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||
|
||||
- uses: extractions/setup-just@95b912dc5d3ed106a72907f2f9b91e76d60bdb76 # 1.5.0
|
||||
|
||||
- name: Add the deployment SSH key
|
||||
uses: shimataro/ssh-key-action@3c9b0fc6f2d223b8450b02a0445f526350fc73e0 # 2.3.1
|
||||
with:
|
||||
|
@ -52,6 +48,6 @@ jobs:
|
|||
path: dist
|
||||
|
||||
- run: |
|
||||
just deploy ${{ github.sha }}
|
||||
./run ci:deploy ${{ github.sha }}
|
||||
|
||||
# vim: sw=2 ts=2
|
||||
|
|
|
@ -6,6 +6,5 @@ flake:
|
|||
devshell:
|
||||
packages:
|
||||
- awscli
|
||||
- just
|
||||
- nodejs_20
|
||||
- yarn
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
devshells.default = {
|
||||
packages = with pkgs; [
|
||||
"awscli"
|
||||
"just"
|
||||
"nodejs_20"
|
||||
"yarn"
|
||||
];
|
||||
|
|
18
justfile
18
justfile
|
@ -1,18 +0,0 @@
|
|||
# https://github.com/casey/just
|
||||
|
||||
default:
|
||||
just --list
|
||||
|
||||
start:
|
||||
nix develop --command yarn astro dev --open
|
||||
|
||||
create-daily date title:
|
||||
#!/usr/bin/env bash
|
||||
nvim $(./tools/scripts/create-daily.sh {{ date }} "{{ title }}")
|
||||
|
||||
deploy sha:
|
||||
rsync -r -avhP --delete dist/* opdavies@104.248.165.137:/srv/oliverdavies.uk
|
||||
|
||||
format:
|
||||
yarn prettier --write src/**/*.{astro,mdx}
|
||||
yarn rustywind src
|
76
run
Executable file
76
run
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
TTY="${TTY:-}"
|
||||
if [[ ! -t 1 ]]; then
|
||||
TTY="-T"
|
||||
fi
|
||||
|
||||
# Build the website within the continuous integration (CI) pipeline.
|
||||
function ci:build {
|
||||
nix develop --command yarn
|
||||
nix develop --command yarn build
|
||||
}
|
||||
|
||||
# Deploy the website within the continuous integration (CI) pipeline.
|
||||
function ci:deploy {
|
||||
rsync -r -avhP --delete dist/* opdavies@104.248.165.137:/srv/oliverdavies.uk
|
||||
}
|
||||
|
||||
# Create a new daily email.
|
||||
function create-daily {
|
||||
local date="${1}"
|
||||
local title="${2}"
|
||||
|
||||
if [ "${date}" == "next" ]; then
|
||||
next_date=$(ls -1 src/content/daily-email | tail -n 1 | tr -d '.md' | xargs -I {} date +%Y-%m-%d -d '{} +1 day')
|
||||
else
|
||||
next_date="${date}"
|
||||
fi
|
||||
|
||||
filepath="src/content/daily-email/${next_date}.md"
|
||||
|
||||
shift 1
|
||||
|
||||
# Generate the title and slug.
|
||||
title="${*}"
|
||||
slug=$(echo "${title}" | \
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
sed 's/[^a-z0-9]/-/g' | \
|
||||
sed 's/\-\-+/-/g' | \
|
||||
sed 's/^\-//;s/\-$//')
|
||||
|
||||
# Create the file.
|
||||
cp -f --no-clobber stub.md "${filepath}"
|
||||
|
||||
date=$(date -d "${next_date}" +%Y-%m-%d)
|
||||
day=$(date -d "${next_date}" +%d)
|
||||
month=$(date -d "${next_date}" +%m)
|
||||
year=$(date -d "${next_date}" +%Y)
|
||||
|
||||
# Replace the placeholders.
|
||||
sed -i "s/{{ date }}/${date}/" "${filepath}"
|
||||
sed -i "s/{{ title }}/${title}/" "${filepath}"
|
||||
sed -i "s#{{ permalink }}#archive/${year}/${month}/${day}/${slug}#" "${filepath}"
|
||||
|
||||
# Create a commit with the appropriate date in the message
|
||||
git add "${filepath}"
|
||||
git commit --quiet -m "daily-email: add ${date}
|
||||
|
||||
${title}"
|
||||
|
||||
echo "${filepath}"
|
||||
}
|
||||
|
||||
# Display a list of all available commands.
|
||||
function help {
|
||||
printf "%s <task> args\n\nTasks:\n" "${0}"
|
||||
|
||||
compgen -A function | grep -v "^_" | cat -n
|
||||
|
||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||
}
|
||||
|
||||
TIMEFORMAT=$'\nTask completed in %3lR'
|
||||
time "${@:-help}"
|
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ "${1}" == "next" ]; then
|
||||
next_date=$(ls -1 src/content/daily-email | tail -n 1 | tr -d '.md' | xargs -I {} date +%Y-%m-%d -d '{} +1 day')
|
||||
else
|
||||
next_date="${1}"
|
||||
fi
|
||||
|
||||
filepath="src/content/daily-email/${next_date}.md"
|
||||
|
||||
shift 1
|
||||
|
||||
# Generate the title and slug.
|
||||
title="${*}"
|
||||
slug=$(echo "${title}" | \
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
sed 's/[^a-z0-9]/-/g' | \
|
||||
sed 's/\-\-+/-/g' | \
|
||||
sed 's/^\-//;s/\-$//')
|
||||
|
||||
# Create the file.
|
||||
cp -f --no-clobber stub.md "${filepath}"
|
||||
|
||||
date=$(date -d "${next_date}" +%Y-%m-%d)
|
||||
day=$(date -d "${next_date}" +%d)
|
||||
month=$(date -d "${next_date}" +%m)
|
||||
year=$(date -d "${next_date}" +%Y)
|
||||
|
||||
# Replace the placeholders.
|
||||
sed -i "s/{{ date }}/${date}/" "${filepath}"
|
||||
sed -i "s/{{ title }}/${title}/" "${filepath}"
|
||||
sed -i "s#{{ permalink }}#archive/${year}/${month}/${day}/${slug}#" "${filepath}"
|
||||
|
||||
# Create a commit with the appropriate date in the message
|
||||
git add "${filepath}"
|
||||
git commit --quiet -m "daily-email: add ${date}
|
||||
|
||||
${title}"
|
||||
|
||||
echo "${filepath}"
|
Loading…
Reference in a new issue