-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (72 loc) · 2.72 KB
/
ci.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: CI
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
inputs:
environment:
description: 'Environment to deploy'
required: true
default: 'development'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_REGION: ${{ secrets.GCP_REGION }}
GCP_ENVIRONMENT: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }}
GCP_CREDENTIALS_JSON: ${{ secrets.GCP_CREDENTIALS_JSON }}
GOOGLE_APPLICATION_CREDENTIALS: ${{ github.workspace }}/credentials.json
jobs:
check-terraform-code:
name: Check Terraform Code
runs-on: ubuntu-latest
environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.8.1
- name: Set up gcloud Cloud SDK environment
uses: google-github-actions/setup-gcloud@v2.1.1
- name: Authenticate to GCP
run: |
echo "${GCP_CREDENTIALS_JSON}" > ${{ github.workspace }}/credentials.json
gcloud auth activate-service-account --key-file=${{ github.workspace }}/credentials.json
gcloud config set project ${{ env.GCP_PROJECT_ID }} # Reemplaza con tu ID de proyecto
- name: Terraform Init
run: terraform init
working-directory: ./infra
- name: Terraform Format
run: terraform fmt -check
working-directory: ./infra
- name: Terraform Validate
run: terraform validate
working-directory: ./infra
- name: Terraform Plan
run: terraform plan
working-directory: ./infra
env:
TF_VAR_environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }}
TF_VAR_project_id: ${{ github.ref == 'refs/heads/main' && env.GCP_PROJECT_ID }}
TF_VAR_region: ${{ env.GCP_REGION }}
# check-python-code:
# name: Check Python Code
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Setup Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.9
# - name: Install dependencies
# run: pip install -r requirements.txt
# - name: Run tests
# run: pytest