-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (40 loc) · 1.67 KB
/
deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 }}"