This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
feat(cd): add dev deployment #36
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: Deployment | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- development | ||
env: | ||
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | ||
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }} | ||
GKE_ZONE: ${{ secrets.GKE_ZONE }} | ||
jobs: | ||
build-container: | ||
name: Build, publish and deploy | ||
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: ${{ env.GKE_CLUSTER }} | ||
location: ${{ env.GKE_ZONE }} | ||
credentials: ${{ secrets.GCP_SA_KEY }} | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
push: true | ||
tags: | | ||
Check failure on line 51 in .github/workflows/deploy.yaml
|
||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }} | ||
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ 'latest' if github.ref == 'refs/heads/main' else 'latest-dev' }} | ||
labels: | | ||
org.opencontainers.image.source=${{ github.event.repository.html_url }} | ||
org.opencontainers.image.revision=${{ github.sha }} | ||
build-args: | | ||
BUILDKIT_INLINE_CACHE=1 | ||
- name: Set up Kustomize | ||
run: |- | ||
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64 | ||
chmod u+x ./kustomize | ||
- name: Deploy (Production) | ||
if: github.ref == 'refs/heads/main' | ||
run: |- | ||
./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 deteccao-alagamento -f - | ||
kubectl rollout status -w -n deteccao-alagamento deployment/deteccao-alagamento | ||
- name: Deploy (Development) | ||
if: github.ref == 'refs/heads/development' | ||
run: |- | ||
./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 deteccao-alagamento-dev -f - | ||
kubectl rollout status -w -n deteccao-alagamento-dev deployment/deteccao-alagamento |