[CI] Try to create staging namespace
This commit is contained in:
		
							parent
							
								
									22378cf133
								
							
						
					
					
						commit
						16117618e1
					
				
					 2 changed files with 81 additions and 43 deletions
				
			
		
							
								
								
									
										120
									
								
								.drone.yml
									
									
									
									
									
								
							
							
						
						
									
										120
									
								
								.drone.yml
									
									
									
									
									
								
							|  | @ -1,43 +1,43 @@ | ||||||
| --- | #--- | ||||||
| kind: pipeline | #kind: pipeline | ||||||
| name: lint | #name: lint | ||||||
| 
 | # | ||||||
| steps: | #steps: | ||||||
| - name: yaml lint | #- name: yaml lint | ||||||
|   image: cytopia/yamllint | #  image: cytopia/yamllint | ||||||
|   commands: | #  commands: | ||||||
|   - yamllint . | #  - yamllint . | ||||||
| 
 | # | ||||||
| - name: docker lint | #- name: docker lint | ||||||
|   image: hadolint/hadolint | #  image: hadolint/hadolint | ||||||
|   commands: | #  commands: | ||||||
|   - hadolint Dockerfile  # ignore pinning version in pip | #  - hadolint Dockerfile  # ignore pinning version in pip | ||||||
| 
 | # | ||||||
| - name: w3c validator | #- name: w3c validator | ||||||
|   image: validator/validator:latest | #  image: validator/validator:latest | ||||||
|   commands: | #  commands: | ||||||
|   - vnu static/*.html | #  - vnu static/*.html | ||||||
| 
 | # | ||||||
| - name: markdown lint | #- name: markdown lint | ||||||
|   image: pipelinecomponents/markdownlint:latest | #  image: pipelinecomponents/markdownlint:latest | ||||||
|   commands: | #  commands: | ||||||
|   - mdl --style all --warnings . | #  - mdl --style all --warnings . | ||||||
| 
 | # | ||||||
| --- | #--- | ||||||
| kind: pipeline | #kind: pipeline | ||||||
| name: unit tests | #name: unit tests | ||||||
| 
 | # | ||||||
| steps: | #steps: | ||||||
| - name: unit test | #- name: unit test | ||||||
|   image: python:slim | #  image: python:slim | ||||||
|   commands: | #  commands: | ||||||
|   - pip install -r requirements.txt | #  - pip install -r requirements.txt | ||||||
|   - pip install pylint | #  - pip install pylint | ||||||
|   - pylint beer/*.py tests/*.py | #  - pylint beer/*.py tests/*.py | ||||||
|   - python -m pytest tests | #  - python -m pytest tests | ||||||
| 
 | # | ||||||
| depends_on: | #depends_on: | ||||||
| - lint | #- lint | ||||||
| 
 | 
 | ||||||
| --- | --- | ||||||
| kind: pipeline | kind: pipeline | ||||||
|  | @ -54,8 +54,42 @@ steps: | ||||||
|     password: |     password: | ||||||
|       from_secret: dockerhub_password |       from_secret: dockerhub_password | ||||||
| 
 | 
 | ||||||
|  | #depends_on: | ||||||
|  | #- unit tests | ||||||
|  | 
 | ||||||
|  | --- | ||||||
|  | kind: pipeline | ||||||
|  | name: deploy | ||||||
|  | 
 | ||||||
|  | steps: | ||||||
|  | - name: deploy | ||||||
|  |   image: sinlead/drone-kubectl | ||||||
|  |   settings: | ||||||
|  |     kubernetes_server: | ||||||
|  |       from_secret: kubectl_uri | ||||||
|  |     kubernetes_cert: | ||||||
|  |       from_secret: kubectl_cert | ||||||
|  |     kubernetes_token: | ||||||
|  |       from_secret: kubectl_token | ||||||
|  |   environment: | ||||||
|  |     IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8} | ||||||
|  |     NAMESPACE: beer-staging-${DRONE_COMMIT_SHA:0:4} | ||||||
|  |   commands: | ||||||
|  |   - echo "== create staging namespace ${NAMESPACE}" | ||||||
|  |   - kubectl get svc --namespace=${NAMESPACE} | ||||||
|  |   - cat kube/beer-deployment.yaml > kube/beer-namespace.yaml | ||||||
|  |   - kubectl apply -f kube/beer-namespace.yaml | ||||||
|  |   - echo "== deploy staging" | ||||||
|  |   - cat kube/beer-deployment.yaml > kube/beer-deployment-${IMAGE_TAG}.yaml | ||||||
|  |   - kubectl apply -f kube/beer-deployment-${IMAGE_TAG}.yaml --namespace=beer | ||||||
|  | 
 | ||||||
| depends_on: | depends_on: | ||||||
| - unit tests | - build | ||||||
|  | 
 | ||||||
|  | when: | ||||||
|  |   branch: | ||||||
|  |     exclude: | ||||||
|  |     - master | ||||||
| 
 | 
 | ||||||
| --- | --- | ||||||
| kind: pipeline | kind: pipeline | ||||||
|  | @ -84,3 +118,7 @@ steps: | ||||||
| 
 | 
 | ||||||
| depends_on: | depends_on: | ||||||
| - build | - build | ||||||
|  | 
 | ||||||
|  | when: | ||||||
|  |   branch: | ||||||
|  |   - master | ||||||
|  |  | ||||||
|  | @ -2,6 +2,6 @@ | ||||||
| apiVersion: v1 | apiVersion: v1 | ||||||
| kind: Namespace | kind: Namespace | ||||||
| metadata: | metadata: | ||||||
|   name: beer |   name: ${NAMESPACE} | ||||||
|   labels: |   labels: | ||||||
|     name: beer |     name: ${NAMESPACE} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue