change image name #19
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 Apply to | |
on: [push, workflow_dispatch] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} | |
DB_HOST: ${{ vars.DB_IP }} | |
DB_USERNAME: ${{ vars.DB_USERNAME}} | |
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | |
DB_NAME: "postgres" | |
IMAGE_NAME: ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app:${{ github.run_id }} | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Set up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GCP_CREDENTIALS }} | |
export_default_credentials: true | |
- name: Configure Docker Client | |
run: |- | |
gcloud auth configure-docker --quiet | |
gcloud auth configure-docker ${{ vars.REGION }}-docker.pkg.dev --quiet | |
- name: Publish docker image on Google Artifactory Registry | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} | |
run: | | |
docker build -t "$IMAGE_NAME" . | |
docker push "$IMAGE_NAME" | |
- name: Configure Kubernetes | |
run: gcloud container clusters get-credentials ${{ vars.prefix }}-${{ vars.PROJECT_ID }}-gke --region ${{ vars.ZONE }} --project ${{ vars.PROJECT_ID }} | |
- name: Install plugins | |
working-directory: k8s/ | |
run: | | |
gcloud components install kubectl | |
gcloud components install gke-gcloud-auth-plugin | |
- name: Deploy deployment to GKE | |
working-directory: k8s/ | |
run: | | |
export IMAGE_NAME=${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app:${{ github.run_id }} | |
kubectl apply -f api-configmap.yaml | |
kubectl apply -f api-deployment.yaml | |
kubectl apply -f api-service.yaml |