diff --git a/.github/workflows/staging.yaml b/.github/workflows/staging.yaml new file mode 100644 index 0000000..9ca3b85 --- /dev/null +++ b/.github/workflows/staging.yaml @@ -0,0 +1,48 @@ +name: Release to staging + +on: + push: + branches: + - main + +# Environment variables available to all jobs and steps in this workflow +env: + GKE_PROJECT: ${{ secrets.GKE_PROJECT_JENKINS }} + GKE_EMAIL: ${{ secrets.GKE_EMAIL_JENKINS }} + GITHUB_SHA: ${{ github.sha }} + +jobs: + setup-build-publish-deploy: + name: Setup, Build, Publish, and Deploy + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Get the version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + + # Setup gcloud CLI + - uses: google-github-actions/setup-gcloud@v0 + with: + version: "270.0.0" + service_account_email: ${{ secrets.GKE_EMAIL_JENKINS }} + service_account_key: ${{ secrets.GKE_KEY_JENKINS }} + + # Setup kubectl + - uses: ThomasKliszowski/setup-kubectl@v1 + with: + kube-config: ${{ secrets.KUBE_CONFIG_DATA }} + kube-version: 1.25.4 + + # Configure docker to use the gcloud command-line tool as a credential helper + - run: | + # Set up docker to authenticate + # via gcloud command-line tool. + gcloud auth configure-docker + + # Build, publish and deploy docker image + - name: Build, publish and deploy docker image + shell: 'script -q -e -c "bash {0}"' + run: | + make build publish deploy diff --git a/Makefile b/Makefile index 3e8f2d0..3031421 100644 --- a/Makefile +++ b/Makefile @@ -121,4 +121,8 @@ destroy-db-volume: ## Destroy Docker volume and all associated data publish: $(DEPLOY_VERSION_FILE) ## Publish latest production Docker image to docker hub docker push $(DEPLOY_VERSION) +deploy: $(DEPLOY_VERSION_FILE) ## Deploy to K8s cluster (e.g. make deploy/{preview,staging,production}) + kubectl set image deployment/config-ew config-ew=$(DEPLOY_VERSION) -n eudiwallet + kubectl set image deployment/service-ew service-ew=$(DEPLOY_VERSION) -n eudiwallet + .DEFAULT_GOAL := help