Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ A good starting place for new github repos.
## Template Status

- ✅ [All github community standards are checked off](https://github.com/fini-net/template-repo/community)
- ✅ [gitattributes](.gitattributes)
- ✅ [gitattributes](.gitattributes) based on [gitattributes](https://github.com/gitattributes/gitattributes)
- ✅ [gitignore](.gitignore) with comments
- ✅ [Issue Templates](.github/ISSUE_TEMPLATE)
- ✅ [PR Template](.github/pull_request_template.md)
- ✅ [CODEOWNERS](.github/CODEOWNERS)
- ✅ [justfile](justfile)
- ✅ [justfile](justfile) with command line workflow for pull requests
- ✅ [Github Action for Markdownlint](.github/workflows)
- ✅ [A few extra labels for issues](https://github.com/fini-net/template-repo/labels)

## Usage

1. Make a new repo and use this repo as your template.
1. Make a new repo and use this repo as your template. You might have to fork it first.
1. Remember to replace any `chicks-net`, `fini-net`, and `template-repo` references
with the right values for your project. (Github templates do not offer
variable substitution, but we still have to call them templaes for some reason.)
1. Ditch the "Template Status" and "Usage" sections in the `README.md`.
variable substitution, but we still have to call them templates for some reason.)
1. Ditch the "Template Status", "Usage", and "Kudos" sections in the `README.md`.

## Contibuting

Expand Down
104 changes: 103 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,107 @@
# project justfile

default:
# some useful variables
host := `uname -n`
release_branch := "main"

# thanks to https://stackoverflow.com/a/7293026/2002471 for the perfect git incantation
last_commit_message := `git log -1 --pretty=%B | grep '.'`

# list recipes (default works without naming it)
[group('example')]
list:
just --list
@echo "{{GREEN}}Your justfile is waiting for more scripts and snippets{{NORMAL}}"

# escape from branch, back to starting point
[group('Process')]
sync:
git checkout main
git pull
git stp

# PR create 3.0
[group('Process')]
pr: on_a_branch
#!/usr/bin/env bash
set -euxo pipefail # strict mode

git stp
git pushup

set +x # leave tracing off...

bodyfile=$(mktemp /tmp/justfile.XXXXXX)

echo "## Done:" >> $bodyfile
echo "" >> $bodyfile
echo "- {{ last_commit_message }}" >> $bodyfile
echo "" >> $bodyfile
echo "" >> $bodyfile
echo "(Automated in \`justfile\`.)" >> $bodyfile

echo ''
cat "$bodyfile"
echo ''

gh pr create --title "{{ last_commit_message }}" --body-file "$bodyfile"
rm "$bodyfile"

if [[ ! -e ".github/workflows" ]]; then
echo "{{BLUE}}there are no workflows in this repo so there are no PR checks to watch{{NORMAL}}"
exit 0
fi

echo "{{BLUE}}sleeping for 10s because github is lazy with their API{{NORMAL}}"
sleep 10
gh pr checks --watch

# merge PR and return to starting point
[group('Process')]
merge:
gh pr merge -s -d
just sync

# start a new branch
[group('Process')]
branch branchname: main_branch
#!/usr/bin/env bash
NOW=`just utcdate`
git co -b "chicks/$NOW-{{ branchname }}"

# view PR in web browser
[group('Process')]
prweb: on_a_branch
gh pr view --web

# error if not on a git branch
[group('sanity check')]
[no-cd]
on_a_branch:
#!/bin/bash

# thanks to https://stackoverflow.com/a/12142066/2002471

if [[ $(git rev-parse --abbrev-ref HEAD) == "main" ]]; then
echo "{{RED}}You are on branch '{{ release_branch }}' (the release branch) so you are not ready to start a PR.{{NORMAL}}"
exit 100
fi

# error if not on the release branch
[group('sanity check')]
[no-cd]
main_branch:
#!/bin/bash

# thanks to https://stackoverflow.com/a/12142066/2002471

if [[ ! $(git rev-parse --abbrev-ref HEAD) == "main" ]]; then
echo "You are on a branch that is not the release branch so you are not ready to start a new branch."
exit 100
fi

# print UTC date in ISO format
[group('Utility')]
[no-cd]
@utcdate:
TZ=UTC date +"%Y-%m-%d"