From 71bbf39d55a930267fcfbc98b5501a30f1c0d76e Mon Sep 17 00:00:00 2001 From: Marcus Noble Date: Fri, 8 May 2020 10:57:47 +0100 Subject: [PATCH] Adde Makefile and remove Jenkinsfile --- Jenkinsfile | 61 ----------------------------------------------------- Makefile | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 61 deletions(-) delete mode 100644 Jenkinsfile create mode 100644 Makefile diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index a15eee3..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,61 +0,0 @@ -pipeline { - agent { label "dind" } - - stages { - - stage('Create Docker image') { - steps { - container('docker') { - sh """ - docker build -t docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} . - """ - } - } - } - - stage('Publish Docker image') { - when { branch 'master' } - environment { - DOCKER_CREDS = credentials('Harbor') - } - steps { - container('docker') { - sh """ - docker login docker.cloud.cluster.fun -u $DOCKER_CREDS_USR -p $DOCKER_CREDS_PSW - docker tag docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} docker.cloud.cluster.fun/averagemarcus/blog:latest - docker push docker.cloud.cluster.fun/averagemarcus/blog:${env.GIT_COMMIT} - docker push docker.cloud.cluster.fun/averagemarcus/blog:latest - """ - } - } - } - - stage('Restart deployment') { - when { branch 'master' } - steps { - container('kubectl') { - sh """ - set +x - mkdir -p ~/.kube/ - printf "\$CLOUD_KUBECONFIG" > ~/.kube/config - kubectl --kubeconfig ~/.kube/config rollout restart deployment/blog --namespace default - """ - } - } - } - - stage('Mirror to GitHub') { - when { branch 'master' } - environment { - GITHUB_TOKEN = credentials('Github_token') - } - steps { - sh """ - git remote add github https://${GITHUB_TOKEN}:@github.com/AverageMarcus/blog.git - git push github HEAD:master - """ - } - } - - } -} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6679661 --- /dev/null +++ b/Makefile @@ -0,0 +1,61 @@ +.DEFAULT_GOAL := default + +IMAGE ?= docker.cloud.cluster.fun/averagemarcus/blog:latest + +.PHONY: test # Run all tests, linting and format checks +test: lint check-format run-tests + +.PHONY: lint # Perform lint checks against code +lint: + @echo "⚠️ 'lint' unimplemented" + +.PHONY: check-format # Checks code formatting and returns a non-zero exit code if formatting errors found +check-format: + @echo "⚠️ 'check-format' unimplemented" + +.PHONY: format # Performs automatic format fixes on all code +format: + @echo "⚠️ 'format' unimplemented" + +.PHONY: run-tests # Runs all tests +run-tests: + @echo "⚠️ 'run-tests' unimplemented" + +.PHONY: fetch-deps # Fetch all project dependencies +fetch-deps: + @npm install + +.PHONY: build # Build the project +build: lint check-format fetch-deps + @echo "⚠️ 'build' unimplemented" + +.PHONY: docker-build # Build the docker image +docker-build: + @docker build -t $(IMAGE) . + +.PHONY: docker-publish # Push the docker image to the remote registry +docker-publish: + @docker push $(IMAGE) + +.PHONY: run # Run the application +run: + @npm start + +.PHONY: ci # Perform CI specific tasks to perform on a pull request +ci: + @echo "⚠️ 'ci' unimplemented" + +.PHONY: release # Release the latest version of the application +release: + @echo "⚠️ 'release' unimplemented" + +.PHONY: help # Show this list of commands +help: + @echo "${REPO_NAME}" + @echo "Usage: make [target]" + @echo "" + @echo "target description" | expand -t20 + @echo "-----------------------------------" + @grep '^.PHONY: .* #' Makefile | sed 's/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20 + +default: test build