ci: start replacing run with just
This commit is contained in:
parent
6d551e354d
commit
7baf281e8a
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
@ -5,9 +5,9 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'README.md'
|
- "README.md"
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 12 15 * *'
|
- cron: "0 12 15 * *"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
@ -18,6 +18,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4
|
||||||
|
- uses: extractions/setup-just@95b912dc5d3ed106a72907f2f9b91e76d60bdb76 # 1.5.0
|
||||||
|
|
||||||
- name: Login to the Docker registry
|
- name: Login to the Docker registry
|
||||||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # v1.10.0
|
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # v1.10.0
|
||||||
|
@ -29,9 +30,7 @@ jobs:
|
||||||
- run: cp .env.example .env
|
- run: cp .env.example .env
|
||||||
working-directory: ./website
|
working-directory: ./website
|
||||||
|
|
||||||
- run: ./run ci:build-images
|
- run: |
|
||||||
working-directory: ./website
|
just push-images ${{ github.sha }}
|
||||||
|
|
||||||
- run: ./run ci:push-images
|
|
||||||
working-directory: ./website
|
|
||||||
# vim: sw=2 ts=2
|
# vim: sw=2 ts=2
|
||||||
|
|
44
justfile
Normal file
44
justfile
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# https://github.com/casey/just
|
||||||
|
|
||||||
|
default:
|
||||||
|
just --list
|
||||||
|
|
||||||
|
create-daily:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
date="$(date +%Y-%m-%d)"
|
||||||
|
filepath="website/source/_daily_emails"
|
||||||
|
filename="${date}.md"
|
||||||
|
|
||||||
|
touch "${filepath}/${filename}"
|
||||||
|
eval "${EDITOR}" "${filepath}/${filename}"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
rm -fr _deploy
|
||||||
|
docker container rm oliverdavies.uk-build || true
|
||||||
|
|
||||||
|
docker image pull ghcr.io/opdavies/oliverdavies.uk-build
|
||||||
|
docker container run --entrypoint sh --name oliverdavies.uk-build ghcr.io/opdavies/oliverdavies.uk-build
|
||||||
|
docker container cp oliverdavies.uk-build:/app/ _deploy
|
||||||
|
|
||||||
|
tree _deploy
|
||||||
|
|
||||||
|
tree -L 2 _deploy
|
||||||
|
|
||||||
|
rsync -r -avhP --delete _deploy/* 104.248.165.137:/srv/oliverdavies.uk
|
||||||
|
|
||||||
|
build-images sha:
|
||||||
|
docker image build \
|
||||||
|
website \
|
||||||
|
-f website/Dockerfile \
|
||||||
|
--target production \
|
||||||
|
-t ghcr.io/opdavies/oliverdavies.uk-build:latest
|
||||||
|
|
||||||
|
docker image build \
|
||||||
|
website \
|
||||||
|
-f website/Dockerfile \
|
||||||
|
--target production \
|
||||||
|
-t ghcr.io/opdavies/oliverdavies.uk-build:{{ sha }}
|
||||||
|
|
||||||
|
push-images sha: (build-images sha)
|
||||||
|
docker image push ghcr.io/opdavies/oliverdavies.uk-build:latest
|
||||||
|
docker image push ghcr.io/opdavies/oliverdavies.uk-build:{{ sha }}
|
34
website/run
34
website/run
|
@ -9,16 +9,6 @@ fi
|
||||||
|
|
||||||
DC="${DC:-exec}"
|
DC="${DC:-exec}"
|
||||||
|
|
||||||
function ci:build-images {
|
|
||||||
docker build --target production -t ghcr.io/opdavies/oliverdavies.uk-build:latest .
|
|
||||||
docker build --target production -t ghcr.io/opdavies/oliverdavies.uk-build:$(git rev-parse HEAD) .
|
|
||||||
}
|
|
||||||
|
|
||||||
function ci:push-images {
|
|
||||||
docker push ghcr.io/opdavies/oliverdavies.uk-build:latest
|
|
||||||
docker push ghcr.io/opdavies/oliverdavies.uk-build:$(git rev-parse HEAD)
|
|
||||||
}
|
|
||||||
|
|
||||||
function cmd {
|
function cmd {
|
||||||
# Run any command in the app container.
|
# Run any command in the app container.
|
||||||
_dc app "${@}"
|
_dc app "${@}"
|
||||||
|
@ -29,11 +19,6 @@ function composer {
|
||||||
_dc --entrypoint composer app "${@}"
|
_dc --entrypoint composer app "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function deploy {
|
|
||||||
cd tools/deployment
|
|
||||||
ansible-playbook deploy.yml "${@}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function help {
|
function help {
|
||||||
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
printf "%s <task> [args]\n\nTasks:\n" "${0}"
|
||||||
|
|
||||||
|
@ -42,25 +27,6 @@ function help {
|
||||||
printf "\nExtended help:\n Each task has comments for general usage\n"
|
printf "\nExtended help:\n Each task has comments for general usage\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
function run-production {
|
|
||||||
DESTINATION_PATH="${2:-/var/www/oliverdavies.uk}"
|
|
||||||
GIT_COMMIT_HASH="${1:-latest}"
|
|
||||||
|
|
||||||
# Clean up any old containers or files within the artifact directory.
|
|
||||||
rm -fr ${DESTINATION_PATH}/* || true
|
|
||||||
|
|
||||||
docker image pull ghcr.io/opdavies/oliverdavies-uk-web:${GIT_COMMIT_HASH}
|
|
||||||
|
|
||||||
docker container run \
|
|
||||||
--entrypoint sh \
|
|
||||||
--name oliverdavies-uk-web \
|
|
||||||
ghcr.io/opdavies/oliverdavies-uk-web:${GIT_COMMIT_HASH}
|
|
||||||
|
|
||||||
docker container cp oliverdavies-uk-web:/code/. ${DESTINATION_PATH}
|
|
||||||
|
|
||||||
docker container rm oliverdavies-uk-web
|
|
||||||
}
|
|
||||||
|
|
||||||
function sh {
|
function sh {
|
||||||
DC=run
|
DC=run
|
||||||
_dc --entrypoint sh app
|
_dc --entrypoint sh app
|
||||||
|
|
Loading…
Reference in a new issue