a better backend deployment workflow
This commit is contained in:
		
							
								
								
									
										23
									
								
								.gitea/workflows/backend_build-deploy-prod.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								.gitea/workflows/backend_build-deploy-prod.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| on: | ||||
|   push: | ||||
|     tags: | ||||
|       - v* | ||||
|  | ||||
| name: Build and deploy the backend to production | ||||
|  | ||||
| jobs: | ||||
|   build-and-push: | ||||
|     name: Build and push image | ||||
|     uses: ./workflow_build-image.yaml | ||||
|     with: | ||||
|       tag: stable | ||||
|     secrets: | ||||
|       PACKAGE_REGISTRY_ACCESS: ${{ secrets.PACKAGE_REGISTRY_ACCESS }} | ||||
|    | ||||
|   deploy-prod: | ||||
|     name: Deploy to production | ||||
|     uses: ./workflow_deploy-container.yaml | ||||
|     with: | ||||
|       environment: prod | ||||
|     secrets: | ||||
|       PACKAGE_REGISTRY_ACCESS: ${{ secrets.KUBE_CONFIG }} | ||||
							
								
								
									
										25
									
								
								.gitea/workflows/backend_build-deploy-stg.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.gitea/workflows/backend_build-deploy-stg.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - main | ||||
|     paths: | ||||
|       - backend/** | ||||
|  | ||||
| name: Build and deploy the backend to staging | ||||
|  | ||||
| jobs: | ||||
|   build-and-push: | ||||
|     name: Build and push image | ||||
|     uses: ./workflow_build-image.yaml | ||||
|     with: | ||||
|       tag: unstable | ||||
|     secrets: | ||||
|       PACKAGE_REGISTRY_ACCESS: ${{ secrets.PACKAGE_REGISTRY_ACCESS }} | ||||
|    | ||||
|   deploy-prod: | ||||
|     name: Deploy to production | ||||
|     uses: ./workflow_deploy-container.yaml | ||||
|     with: | ||||
|       environment: stg | ||||
|     secrets: | ||||
|       PACKAGE_REGISTRY_ACCESS: ${{ secrets.KUBE_CONFIG }} | ||||
| @@ -1,12 +1,17 @@ | ||||
| on: | ||||
|   pull_request: | ||||
|     branches: | ||||
|       - main | ||||
|     paths: | ||||
|       - backend/** | ||||
|   workflow_call: | ||||
|     inputs: | ||||
|       tag: | ||||
|         required: true | ||||
|         type: string | ||||
|     secrets: | ||||
|       PACKAGE_REGISTRY_ACCESS: | ||||
|         required: true | ||||
| 
 | ||||
| 
 | ||||
| name: Build and push docker image | ||||
| 
 | ||||
| 
 | ||||
| jobs: | ||||
|   build: | ||||
|     name: Build | ||||
| @@ -29,5 +34,5 @@ jobs: | ||||
|       uses: docker/build-push-action@v5 | ||||
|       with: | ||||
|         context: backend | ||||
|         tags: git.kluster.moll.re/anydev/anyway-backend:latest | ||||
|         tags: git.kluster.moll.re/anydev/anyway-backend:${{intputs.tag}} | ||||
|         push: true | ||||
							
								
								
									
										34
									
								
								.gitea/workflows/workflow_deploy-container.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								.gitea/workflows/workflow_deploy-container.yaml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| on: | ||||
|   workflow_call: | ||||
|     inputs: | ||||
|       overlay: | ||||
|         required: true | ||||
|         type: string | ||||
|     secrets: | ||||
|       KUBE_CONFIG: | ||||
|         required: true | ||||
|  | ||||
|  | ||||
| name: Deploy the newly built container | ||||
|  | ||||
|  | ||||
| jobs: | ||||
|   deploy: | ||||
|     name: Deploy | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|  | ||||
|     - uses: https://gitea.com/actions/checkout@v4 | ||||
|       with: | ||||
|         submodules: true | ||||
|  | ||||
|     - name: setup kubectl | ||||
|       uses: https://github.com/azure/setup-kubectl@v4 | ||||
|  | ||||
|     - name: Set kubeconfig | ||||
|       run: | | ||||
|         echo "${{ secrets.KUBE_CONFIG }}" > kubeconfig | ||||
|  | ||||
|     - name: Deploy to k8s | ||||
|       run: | | ||||
|         kubectl apply -k backend/deployment/overlays/${{ inputs.overlay }} --kubeconfig=kubeconfig | ||||
		Reference in New Issue
	
	Block a user