Commit 9957486f authored by J. Fernando Sánchez's avatar J. Fernando Sánchez
Browse files

Merge branch 'gsictl' into 'master'

Gsictl

See merge request docs/templates/makefiles!3
parents 2ca9d36f 0dc93fc1
...@@ -5,7 +5,7 @@ To add them to your project, simply do: ...@@ -5,7 +5,7 @@ To add them to your project, simply do:
git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git
git subtree add --prefix=.makefiles/ makefiles master git subtree add --prefix=.makefiles/ makefiles master
touch Makefile touch Makefile
echo "include .makefiles/makefiles.mk" >> Makefile echo "include .makefiles/base.mk" >> Makefile
``` ```
Now you can take advantage of the recipes. Now you can take advantage of the recipes.
......
NAME ?= $(shell basename $(CURDIR))
VERSION ?= $(shell git describe --tags --dirty 2>/dev/null) VERSION ?= $(shell git describe --tags --dirty 2>/dev/null)
# Get the location of this makefile.
MK_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
.FORCE: .FORCE:
version: .FORCE version: .FORCE
...@@ -20,5 +23,8 @@ config: ## Load config from the environment. You should run it once in every se ...@@ -20,5 +23,8 @@ config: ## Load config from the environment. You should run it once in every se
ci: ## Run a task using gitlab-runner. Only use to debug problems in the CI pipeline ci: ## Run a task using gitlab-runner. Only use to debug problems in the CI pipeline
gitlab-runner exec shell --builds-dir '.builds' --env CI_PROJECT_NAME=$(NAME) ${action} gitlab-runner exec shell --builds-dir '.builds' --env CI_PROJECT_NAME=$(NAME) ${action}
include $(MK_DIR)/makefiles.mk
include $(MK_DIR)/docker.mk
include $(MK_DIR)/git.mk
.PHONY:: config help ci version .FORCE .PHONY:: config help ci version .FORCE
IMAGEWTAG ?= $(IMAGENAME):$(VERSION) IMAGEWTAG ?= $(IMAGENAME):$(VERSION)
login: ## Log in to the registry. It will only be used in the server, or when running a CI task locally (if CI_BUILD_TOKEN is set). docker-login: ## Log in to the registry. It will only be used in the server, or when running a CI task locally (if CI_BUILD_TOKEN is set).
ifeq ($(CI_BUILD_TOKEN),) ifeq ($(CI_BUILD_TOKEN),)
@echo "Not logging in to the docker registry" "$(CI_REGISTRY)" @echo "Not logging in to the docker registry" "$(CI_REGISTRY)"
else else
...@@ -12,10 +12,14 @@ else ...@@ -12,10 +12,14 @@ else
@docker login -u $(HUB_USER) -p $(HUB_PASSWORD) @docker login -u $(HUB_USER) -p $(HUB_PASSWORD)
endif endif
clean:: ## Remove docker credentials docker-clean: ## Remove docker credentials
ifeq ($(HUB_USER),) ifeq ($(HUB_USER),)
else else
@docker logout @docker logout
endif endif
.PHONY:: login clean login:: docker-login
clean:: docker-clean
.PHONY:: docker-login docker-clean login clean
git_commit: commit:
git commit -a git commit -a
git_tag: tag:
git tag ${VERSION} git tag ${VERSION}
git_push: git-push::
git push --tags origin master git push --tags -u origin HEAD
push-github: ## Push the code to github. You need to set up HUB_USER and HUB_PASSWORD git-pull:
git pull --all
push-github: ## Push the code to github. You need to set up GITHUB_DEPLOY_KEY
ifeq ($(GITHUB_DEPLOY_KEY),)
else
$(eval KEY_FILE := $(shell mktemp)) $(eval KEY_FILE := $(shell mktemp))
@echo "$$GITHUB_DEPLOY_KEY" > $(KEY_FILE) @echo "$(GITHUB_DEPLOY_KEY)" > $(KEY_FILE)
@git remote rm github-deploy || true @git remote rm github-deploy || true
git remote add github-deploy $(GITHUB_REPO) git remote add github-deploy $(GITHUB_REPO)
@GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git fetch github-deploy $(CI_COMMIT_REF_NAME) || true @GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git fetch github-deploy $(CI_COMMIT_REF_NAME) || true
@GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git push github-deploy $(CI_COMMIT_REF_NAME) @GIT_SSH_COMMAND="ssh -i $(KEY_FILE)" git push github-deploy $(CI_COMMIT_REF_NAME)
rm $(KEY_FILE) rm $(KEY_FILE)
endif
push:: git-push
pull:: git-pull
.PHONY:: git_commit git_tag git_push push-github .PHONY:: commit tag push git-push git-pull push-github
makefiles-remote: makefiles-remote:
git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git || true @git remote add makefiles ssh://git@lab.cluster.gsi.dit.upm.es:2200/docs/templates/makefiles.git 2>/dev/null || true
makefiles-commit: makefiles-remote makefiles-commit: makefiles-remote
git add -f .makefiles git add -f .makefiles
...@@ -11,4 +11,7 @@ makefiles-push: ...@@ -11,4 +11,7 @@ makefiles-push:
makefiles-pull: makefiles-remote makefiles-pull: makefiles-remote
git subtree pull --prefix=.makefiles/ makefiles master --squash git subtree pull --prefix=.makefiles/ makefiles master --squash
.PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull pull:: makefiles-pull
push:: makefiles-push
.PHONY:: makefiles-remote makefiles-commit makefiles-push makefiles-pull pull push
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment