Deploy Demo App To Staging After Merge #262
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Demo App | |
run-name: Deploy Demo App To Staging After Merge | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
actions: read | |
contents: read | |
security-events: write | |
steps: | |
- name: 💾 Checking out the repository | |
uses: actions/checkout@v4 | |
- name: ⚙️ Setting up the MonkJs project | |
uses: ./.github/actions/monkjs-set-up | |
with: | |
build-env: production | |
- name: 📱 Building the demo app | |
run: cd apps/demo-app && yarn build:staging | |
- name: 📦 Uploading the artifact | |
uses: actions/upload-artifact@v4.3.1 | |
with: | |
name: build-demo-app-staging | |
path: apps/demo-app/build | |
if-no-files-found: error | |
deploy: | |
name: Deploy | |
environment: staging | |
needs: | |
- build | |
container: | |
image: dtzar/helm-kubectl:3.14.2 | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🔐 Authenticating to Google Cloud | |
uses: google-github-actions/auth@v2.1.2 | |
with: | |
credentials_json: "${{ secrets.GKE_SA_KEY }}" | |
- name: 🔐 Obtaining GKE credentials | |
uses: google-github-actions/get-gke-credentials@v2.1.0 | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_ZONE }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
- name: 📦 Downloading the artifact | |
uses: actions/download-artifact@v4.1.4 | |
with: | |
name: build-demo-app-staging | |
path: demo | |
- name: 🧹 Cleaning up previous build | |
run: |- | |
kubectl -n poc exec -it $(kubectl get pods -n poc -l app.kubernetes.io/instance=poc-spa --no-headers | awk '{print $1}') -- rm -rf demo | |
- name: 🌐 Deploying app | |
run: |- | |
kubectl -n poc cp demo poc/$(kubectl get pods -n poc -l app.kubernetes.io/instance=poc-spa --no-headers | awk '{print $1}'):/app/ |