Merge pull request #37 from tribofustack/feat/sonarqube #29
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: Apply | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
jobs: | |
apply: | |
runs-on: ubuntu-latest | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.CREDENTIALS }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v3 | |
- name: Auth GCloud | |
uses: "google-github-actions/[email protected]" | |
with: | |
credentials_json: ${{ secrets.CREDENTIALS }} | |
export_environment_variables: true | |
create_credentials_file: true | |
- name: Set up Cloud SDK | |
uses: "google-github-actions/setup-gcloud@v2" | |
- name: Use gcloud CLI | |
run: gcloud container clusters list | |
- name: Setup Cluster Kubernetes | |
uses: "google-github-actions/get-gke-credentials@v2" | |
with: | |
cluster_name: ${{ vars.CLUSTER_NAME }} | |
location: ${{ vars.ZONE }} | |
- name: Configure Docker Client | |
run: |- | |
gcloud auth configure-docker --quiet | |
gcloud auth configure-docker ${{ vars.REGION }}-docker.pkg.dev --quiet | |
- name: Publish docker image | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.CREDENTIALS }} | |
run: | | |
docker build -t ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/repository/app:${{ github.run_id }} . | |
docker push ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/repository/app:${{ github.run_id }} | |
- name: Setup Namespace | |
run: kubectl config set-context --current --namespace=orderly | |
- name: Create ConfigMap | |
working-directory: k8s/ | |
run: | | |
echo "$(cat api-configmap.yaml)" | envsubst | kubectl apply -f - | |
env: | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
DB_IP: ${{ vars.DB_IP }} | |
DB_USERNAME: ${{ vars.DB_USERNAME }} | |
DB_NAME: ${{ vars.DB_NAME }} | |
- name: apply api | |
env: | |
IMAGE_NAME: ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/repository/app:${{ github.run_id }} | |
run: | | |
echo "$(cat k8s/api-deployment.yaml)" | envsubst | kubectl apply -f - | |
kubectl apply -f k8s/api-hpa.yaml | |
kubectl apply -f k8s/api-service.yaml |