-
Notifications
You must be signed in to change notification settings - Fork 24
64 lines (49 loc) · 1.78 KB
/
deploy.yml
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
52
53
54
55
56
57
58
59
60
61
62
63
64
name: 'Deploy with Terraform'
on: workflow_dispatch
permissions: read-all
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup Terraform
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@62cf5bd3e4211a0a0b51f2c6d6a37129d828611d # v2.1.5
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.TF_GOOGLE_CREDENTIALS }}
export_environment_variables: true
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@f0990588f1e5b5af6827153b93673613abdc6ec7 # v2.1.1
- name: Configure gcloud
run: gcloud config set project ${{ secrets.GOOGLE_PROJECT_ID }}
- name: Generate the images for each feed
run: gcloud builds submit --tag gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/scheduled-feeds
- name: Terraform Init
run: terraform init
working-directory: ./terraform
- name: Terraform Format
run: terraform fmt -check
working-directory: ./terraform
- name: Terraform Plan
run: terraform plan
working-directory: ./terraform
- name: Terraform Apply
if: github.ref == 'refs/heads/main'
run: terraform apply -auto-approve
working-directory: ./terraform
- name: Deploy to Cloud Run
if: github.ref == 'refs/heads/main'
run: |
gcloud run deploy \
scheduled-feeds-srv \
--platform managed \
--region us-central1 \
--max-instances=1 \
--image gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/scheduled-feeds;