VAST-260 changed the resources #3
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 to Google Cloud | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
workflow_dispatch: | ||
env: | ||
PROJECT_ID: ${{ secrets.PROJECT_ID }} | ||
REGION: ${{ secrets.REGION }} | ||
REPOSITORY_NAME: "keycloak-repo" # Must be local.registry_name | ||
IMAGE_NAME: "keycloak-image" # @todo is it right? | ||
IMAGE_TAG: "latest" # default?? | ||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Google Cloud credentials | ||
uses: google-github-actions/auth@v1 | ||
with: | ||
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }} | ||
- name: Configure Docker | ||
run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev | ||
- name: Build Docker image | ||
run: | | ||
# "europe-west6-docker.pkg.dev/keycloak-dev-399613/keycloak/keycloak@sha256:0eeed2228ff032040510f2b478f1bb475693179018cfd5587d9a0cc1d7c5716e" | ||
docker build -t ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} . | ||
- name: Push Docker image to Google Artifact Registry | ||
run: | | ||
docker push ${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||
- name: Set up Terraform | ||
uses: hashicorp/setup-terraform@v1 | ||
with: | ||
terraform_wrapper: false | ||
- name: Terraform Init | ||
run: terraform init | ||
- name: Terraform Apply | ||
run: | | ||
terraform apply -auto-approve -var="project_id=${{ env.PROJECT_ID }}" -var="region=${{ env.REGION }}" -var="image=${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.IMAGE_TAG }}" |