diff options
author | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2023-12-30 16:38:02 +0100 |
commit | 458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d (patch) | |
tree | 0ba3319ddb214bc65dd402de13939cb9ca283574 /deploy.py | |
parent | 9ee28abd5041ebbbc8acd39ddc84ca37e7255076 (diff) | |
parent | 58d54c5debedca8c91b28026f520b226ac8682f6 (diff) | |
download | blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.tar.gz blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.tar.bz2 blog-458a5fdfc598517b9fbddd02d3e1ae7cc70ceb9d.zip |
deploy.py auto-commitdeploy
Diffstat (limited to 'deploy.py')
-rw-r--r-- | deploy.py | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/deploy.py b/deploy.py deleted file mode 100644 index 129d53b..0000000 --- a/deploy.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 - -import os -import tempfile -import subprocess -from pathlib import Path - -if __name__ == '__main__': - with tempfile.TemporaryDirectory() as tmpdir: - pagefind = Path('~/.cargo/bin/pagefind').expanduser() - pagefind = str(pagefind) if pagefind.is_file() else 'pagefind' - - current_branch = subprocess.run(['git', 'symbolic-ref', '-q', 'HEAD'], check=False, capture_output=True).stdout.strip() - if current_branch == 'refs/heads/deploy': - raise SystemError('This script cannot be run from the deploy branch (run from main instead)') - - subprocess.run(['git', 'worktree', 'add', '--detach', tmpdir], check=True) - try: - env = dict(os.environ) - env['PATH'] = f'{Path("hack").absolute()}:{env["PATH"]}' - subprocess.run(['hugo'], cwd=tmpdir, check=True, env=env) - subprocess.run([pagefind, '--site', 'public'], cwd=tmpdir, check=True, env=env) - subprocess.run(['git', 'add', '--force', 'public'], cwd=tmpdir, check=True) - write_tree = subprocess.run(['git', 'write-tree', '--prefix=public/'], cwd=tmpdir, check=True, capture_output=True) - tree = write_tree.stdout.strip() - - commit = subprocess.run(['git', 'commit-tree', '-p', 'HEAD', '-p', 'refs/heads/deploy', '-m', 'deploy.py auto-commit', tree], cwd=tmpdir, check=True, capture_output=True).stdout.strip() - subprocess.run(['git', 'update-ref', '-m', f'deploy.sh update deploy branch to {commit}', 'refs/heads/deploy', commit], cwd=tmpdir, check=True) - - subprocess.run(['git', 'push', 'git@git.jaseg.de:blog.git', 'deploy'], cwd=tmpdir, check=True) - finally: - subprocess.run(['git', 'worktree', 'remove', '-f', tmpdir], check=True) |