-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (56 loc) · 2.26 KB
/
Makefile
File metadata and controls
67 lines (56 loc) · 2.26 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
.PHONY: help start stop restart logs status clean
REPO_OWNER := devxpod
REPO_NAME := oauth42
GITHUB_URL := https://github.com/$(REPO_OWNER)/$(REPO_NAME)
help: ## Show this help message
@echo "GitHub Actions Self-Hosted Runner Management"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Note: This runner uses a Personal Access Token (PAT) from the .env file"
@echo "Make sure your GITHUB_TOKEN in .env has the 'repo' and 'workflow' scopes"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'
start: ## Start the runner
@echo "Starting GitHub Actions runner..."
@if [ ! -f .env ]; then \
echo "Error: .env file not found!"; \
echo "Create .env with:"; \
echo " GITHUB_URL=https://github.com/YOUR_USERNAME/YOUR_REPO"; \
echo " GITHUB_TOKEN=<your-PAT>"; \
exit 1; \
fi
@export $$(grep -v '^#' .env | xargs) && \
GITHUB_USER=$$(echo $$GITHUB_URL | sed -E 's|https://github.com/([^/]+).*|\1|') && \
export RUNNER_LABELS="$${RUNNER_LABELS:-self-hosted,Linux,ARM64,amazonlinux},$$GITHUB_USER" && \
echo "Detected GitHub username: $$GITHUB_USER" && \
echo "Runner labels: $$RUNNER_LABELS" && \
docker compose up -d
@echo ""
@echo "Runner started! Use 'make logs' to view output"
@echo "Use 'make status' to check runner status"
stop: ## Stop the runner
@echo "Stopping GitHub Actions runner..."
docker compose down
@echo "Runner stopped"
restart: stop start ## Restart the runner with a fresh token
logs: ## Show runner logs (follow mode)
docker compose logs -f
logs-tail: ## Show last 50 lines of runner logs
docker compose logs --tail=50
status: ## Check runner status
@echo "Docker Container Status:"
@docker compose ps
@echo ""
@echo "Registered Runners in GitHub:"
@gh api /repos/$(REPO_OWNER)/$(REPO_NAME)/actions/runners | jq -r '.runners[] | "\(.name) - Status: \(.status) - Labels: \(.labels | map(.name) | join(", "))"'
clean: stop ## Stop runner and remove all containers and volumes
@echo "Cleaning up..."
docker compose down -v
@echo "Cleanup complete"
build: ## Rebuild the Docker image
@echo "Building Docker image..."
docker compose build --no-cache
@echo "Build complete"
rebuild: build start ## Rebuild image and start runner with fresh token