Skip to content

fix(cd): typo

fix(cd): typo #3

Workflow file for this run

name: API
on:
push:
paths:
- ".github/workflows/api*"
- "api/**/*"
jobs:
lint:
name: Lint (${{ matrix.os }}${{ matrix.arch }} Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
arch: [x64]
python-version: ["3.11.x"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.arch }}
- name: Set up dependencies
run: |
cd api/
pip install -U pip poetry
poetry config virtualenvs.create false
poetry install --with dev
- name: Run linters
run: |
cd api/
task lint
tests:
name: Test (${{ matrix.os }}${{ matrix.arch }} Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
env:
INFISICAL_ADDRESS: ${{ secrets.INFISICAL_ADDRESS }}
INFISICAL_TOKEN: ${{ secrets.INFISICAL_TOKEN }}
strategy:
matrix:
os: [ubuntu-latest]
arch: [x64]
python-version: ["3.11.x"]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.arch }}
- name: Set up dependencies
run: |
cd api/
pip install -U pip poetry
poetry config virtualenvs.create false
poetry install --with dev
- name: Run tests
run: |
cd api/
task test
deploy:
name: Build and Deploy
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/development'
needs: [lint, tests]
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: Build and push image
uses: docker/build-push-action@v2
with:
context: api/
file: api/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref == 'refs/heads/main' && 'latest' || github.ref == 'refs/heads/development' && 'latest-dev' || github.sha }}
labels: |
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
build-args: |
BUILDKIT_INLINE_CACHE=1
- 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_ZONE }}
credentials: ${{ secrets.GCP_SA_KEY }}
- 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
mv ./kustomize api/
- name: Deploy (main)
if: github.ref == 'refs/heads/main'
run: |-
cd api/
./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 unificacao-prontuarios-prod -f -
cat <<EOF | kubectl apply -n unificacao-prontuarios-prod -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: unificacao-prontuarios-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: "letsencrypt"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- unificacao-prontuarios.dados.rio
secretName: unificacao-prontuarios-tls
rules:
- host: unificacao-prontuarios.dados.rio
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: unificacao-prontuarios
port:
number: 80
EOF
kubectl rollout status -w -n unificacao-prontuarios-prod deployment/unificacao-prontuarios
- name: Deploy (development)
if: github.ref == 'refs/heads/development'
run: |-
cd api/
./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 unificacao-prontuarios-dev -f -
cat <<EOF | kubectl apply -n unificacao-prontuarios-prod -f -
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: unificacao-prontuarios-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /
cert-manager.io/cluster-issuer: "letsencrypt"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- unificacao-prontuarios-dev.dados.rio
secretName: unificacao-prontuarios-tls
rules:
- host: unificacao-prontuarios-dev.dados.rio
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: unificacao-prontuarios
port:
number: 80
EOF
kubectl rollout status -w -n unificacao-prontuarios-dev deployment/unificacao-prontuarios