Merge pull request #155 from prefeitura-rio/mobile-version #140
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 : CD (Development) | |
on: | |
push: | |
branches: | |
- development | |
env: | |
DOCKER_IMAGE_TAG: latest | |
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG_DEV }} | |
K8S_DEPLOYMENT_NAME: mapa-realizacoes-dev | |
K8S_NAMESPACE: mapa-realizacoes | |
KUSTOMIZE_DIRECTORY: .kubernetes/dev | |
KUSTOMIZE_VERSION: "5.x" | |
jobs: | |
build: | |
name: Build container | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create firebaseconfig.js | |
run: echo $FIREBASE_CONFIG | base64 --decode > ./src/firebaseconfig.js | |
- name: Build and push image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} | |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ env.DOCKER_IMAGE_TAG }} | |
labels: | | |
org.opencontainers.image.source=${{ github.event.repository.html_url }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
build-args: | | |
BUILDKIT_INLINE_CACHE=1 | |
deploy: | |
needs: build | |
name: Deploy to Kubernetes | |
runs-on : ubuntu-latest | |
steps: | |
- name : Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Google Cloud CLI | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
export_default_credentials: true | |
- name: Get GKE credentials | |
uses: google-github-actions/[email protected] | |
with: | |
cluster_name: ${{ secrets.GKE_CLUSTER }} | |
location: ${{ secrets.GKE_LOCATION }} | |
credentials: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up Kustomize | |
uses: imranismail/setup-kustomize@v2 | |
with: | |
kustomize-version: ${{ env.KUSTOMIZE_VERSION }} | |
- name: Deploy | |
run: |- | |
cd $KUSTOMIZE_DIRECTORY | |
kustomize edit set image gcr.io/PROJECT_ID/IMAGE_NAME:TAG=ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} | |
kustomize build . | kubectl apply -n $K8S_NAMESPACE -f - | |
kubectl rollout status -w -n $K8S_NAMESPACE deployment/$K8S_DEPLOYMENT_NAME |