summaryrefslogtreecommitdiff
path: root/f3s/forgejo/Justfile
blob: e7c4cad852c5ae5731ad1727c3d54420dc23f3eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
NAMESPACE := "services"
APP_NAME := "forgejo"

status:
    @echo "=== Pods ==="
    @kubectl get pods -n {{NAMESPACE}} | grep forgejo
    @echo ""
    @echo "=== Services ==="
    @kubectl get svc -n {{NAMESPACE}} forgejo forgejo-ssh
    @echo ""
    @echo "=== Ingress ==="
    @kubectl get ingress -n {{NAMESPACE}} forgejo-ingress forgejo-ingress-lan
    @echo ""
    @echo "=== PVCs ==="
    @kubectl get pvc -n {{NAMESPACE}} | grep forgejo
    @echo ""
    @echo "=== ArgoCD Status ==="
    @kubectl get application {{APP_NAME}} -n cicd -o jsonpath='Sync: {.status.sync.status}, Health: {.status.health.status}' 2>/dev/null && echo ""

logs lines="100":
    kubectl logs -n {{NAMESPACE}} -l app=forgejo --tail={{lines}} -f

port-forward port="3000":
    @echo "Forwarding forgejo to localhost:{{port}}"
    kubectl port-forward -n {{NAMESPACE}} svc/forgejo {{port}}:80

sync:
    @echo "Triggering ArgoCD sync..."
    @kubectl annotate application {{APP_NAME}} -n cicd argocd.argoproj.io/refresh=normal --overwrite
    @sleep 2
    @kubectl get application {{APP_NAME}} -n cicd -o jsonpath='Sync: {.status.sync.status}, Health: {.status.health.status}' && echo ""

restart:
    @echo "Restarting forgejo..."
    kubectl rollout restart -n {{NAMESPACE}} deployment/forgejo

# One-time after the first successful start. This is the ONLY way in: the web
# installer is locked and registration is disabled.
# `admin user create` does not prompt -- without --password or --random-password
# it exits with "must set either password or random-password flag". Use a
# generated password (printed once, to stdout) rather than passing one on the
# command line where it would land in shell history and ps output.
create-admin username="paul" email="paul.buetow@gmail.com":
    @echo "The generated password is printed below -- copy it now, it is shown only once."
    kubectl exec -n {{NAMESPACE}} -it deploy/forgejo -- \
        forgejo admin user create --admin --username {{username}} --email {{email}} \
        --random-password

# Open a shell as the git user inside the running instance.
shell:
    kubectl exec -n {{NAMESPACE}} -it deploy/forgejo -- /bin/sh