-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
79 lines (66 loc) · 2.78 KB
/
Makefile
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
68
69
70
71
72
73
74
75
76
77
78
79
.PHONY: all
all: projects/mirrors projects/repo-dockerfiles projects/forks ## Run all the generation scripts.
.PHONY: projects/mirrors
projects/mirrors: generate-mirrors.sh ## Generate DSLs for git mirrors.
@echo "+ $@"
./$< | column -t
.PHONY: projects/repo-dockerfiles
projects/repo-dockerfiles: generate-repo-dockerfiles.sh ## Generate DSLs for repos with Dockerfiles.
@echo "+ $@"
./$< | column -t
.PHONY: projects/forks
projects/forks: generate-update-forks.sh ## Generate DSLs to update git forks.
@echo "+ $@"
./$< | column -t
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))$(if $(value @), \
required by target `$@')))
.PHONY: deploy-key
deploy-key: ## Create a deploy key for a given repo (ex. REPO=jessfraz/jenkins-dsl).
@:$(call check_defined, REPO, name of the repository)
@$(CURDIR)/create-deploy-key.sh "$(REPO)"
.PHONY: webhook-jenkins-create
webhook-jenkins-create: ## Create the jenkins webhook for a given repo (ex. REPO=jessfraz/jenkins-dsl).
@:$(call check_defined, REPO, name of the repository)
@$(CURDIR)/create-jenkins-webhook.sh "$(REPO)"
GITHUB_API_URI:=https://api.github.com
GITHUB_API_VERSION:=v3
GITHUB_API_HEADER:=Accept: application/vnd.github.$(GITHUB_API_VERSION)+json
GITHUB_AUTH_HEADER:=Authorization: token ${GITHUB_TOKEN}
.PHONY: webhook-jenkins-get
webhook-jenkins-get: ## Get the jenkins webhook for a given repo (ex. REPO=jessfraz/jenkins-dsl).
@:$(call check_defined, REPO, name of the repository)
@curl -sSL \
-H "$(GITHUB_AUTH_HEADER)" \
-H "$(GITHUB_API_HEADER)" \
"$(GITHUB_API_URI)/repos/$(REPO)/hooks" | jq '.[] | select(.name=="web")'
.PHONY: webhook-travis-get
webhook-travis-get: ## Get a travis webhook for a given repo (ex. REPO=jessfraz/jenkins-dsl).
@:$(call check_defined, REPO, name of the repository)
@curl -sSL \
-H "$(GITHUB_AUTH_HEADER)" \
-H "$(GITHUB_API_HEADER)" \
"$(GITHUB_API_URI)/repos/$(REPO)/hooks" | jq '.[] | select(.name=="travis")'
.PHONY: test
test: shellcheck ## Runs all the tests on the files in the repository.
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
endif
.PHONY: shellcheck
shellcheck: ## Runs the shellcheck tests on the scripts.
docker run --rm -i $(DOCKER_FLAGS) \
--name df-shellcheck \
-v $(CURDIR):/usr/src:ro \
--workdir /usr/src \
r.j3ss.co/shellcheck ./test.sh
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'