Skip to content

Commit 6f30dd3

Browse files
committed
Improve build.sh
1 parent 4488fac commit 6f30dd3

2 files changed

Lines changed: 28 additions & 5 deletions

File tree

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373

7474
- name: Run latexmk
7575
run: |
76-
./build.sh "$GITHUB_WORKSPACE"
76+
./build.sh -w ${{ github.workspace }}
7777
7878
- name: Create Release
7979
uses: softprops/action-gh-release@v2

build.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1-
#!/bin/sh
1+
#!/bin/sh -l
22

3-
readonly WORK_DIR="${1:-$(pwd)}"
3+
# Constants
44
readonly MOUNT_POINT='/workspace'
5-
readonly USER='ubuntu'
65

7-
docker run --rm --entrypoint="" -v "$WORK_DIR:$MOUNT_POINT" -w $MOUNT_POINT -u $USER ghcr.io/quasar6x/thesis-builder:latest latexmk
6+
usage() { echo "Usage: $0 -u <DOCKER_USERNAME> -w <WORK_DIR> [-h]" 1>&2; exit 1; }
7+
8+
unset -v DOCKER_USERNAME WORK_DIR
9+
while getopts ":u:w:h" opt; do
10+
case $opt in
11+
u)
12+
DOCKER_USERNAME="$OPTARG"
13+
;;
14+
w)
15+
WORK_DIR="${OPTARG:-$(pwd)}"
16+
;;
17+
h|*)
18+
usage
19+
;;
20+
esac
21+
done
22+
23+
# Set WORK_DIR if it was not sent on the CLI
24+
WORK_DIR="${WORK_DIR:-$(pwd)}"
25+
26+
docker run --rm \
27+
-v "$WORK_DIR:$MOUNT_POINT" \
28+
-w "$MOUNT_POINT" \
29+
-u "$DOCKER_USERNAME" \
30+
ghcr.io/quasar6x/thesis-builder:latest latexmk

0 commit comments

Comments
 (0)