Skip to content

Commit

Permalink
Merge pull request #44 from Fgruntjes/initial-build
Browse files Browse the repository at this point in the history
deploy test
  • Loading branch information
Fgruntjes authored Oct 12, 2022
2 parents 3249a83 + c562d10 commit 366789a
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 16 deletions.
24 changes: 18 additions & 6 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ jobs:
region: [ 'europe-central2' ]
steps:
- uses: actions/checkout@v3
- uses: google-github-actions/auth@v0
id: google_auth
with:
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
# Deploy function
- run: echo "slug=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV
- uses: actions/github-script@v6
id: environment
Expand All @@ -77,18 +83,24 @@ jobs:
DOTNET_ENVIRONMENT: ${{ steps.environment.outputs.result }}
IMAGE: gcr.io/${{ secrets.GOOGLE_PROJECT_ID }}/${{ matrix.project.service }}:${{env.slug}}
Database__ConnectionString: ${{ secrets.DATABASE__CONNECTIONSTRING }}
Database__DatabaseName: ${{steps.environment.outputs.result}}
Database__DatabaseName: ${{ steps.environment.outputs.result }}
Sentry__Dsn: ${{ secrets.SENTRY__DSN }}
with:
in-file: ${{ matrix.project.name }}/service.yaml
out-file: ${{ matrix.project.name }}/service.deploy.yaml
- run: cat ${{ matrix.project.name }}/service.deploy.yaml
- uses: google-github-actions/auth@v0
id: google_auth
with:
workload_identity_provider: ${{ secrets.GOOGLE_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
- uses: google-github-actions/deploy-cloudrun@v0
id: cloudrun
with:
metadata: ${{ matrix.project.name }}/service.deploy.yaml
region: ${{ matrix.region }}
# Deploy infra (terraform)
- uses: hashicorp/setup-terraform@v2
- run: |
test -d ${{ matrix.project.name }}/terraform || exit 0
cd ${{ matrix.project.name }}/terraform
terraform init
terraform plan \
-var "environment=${{ env.environment_lowercase }}" \
-var "cloudrun_url=${{ steps.cloudrun.outputs.url }}"
terraform apply
22 changes: 20 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
#########################################################
# Code quality and unit tests
#########################################################
test_quality:
test_quality_dotnet:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -18,8 +18,26 @@ jobs:
with:
dotnet-version: ${{ matrix.dotnet-version }}
- run: dotnet format --verify-no-changes


test_quality_terraform:
runs-on: ubuntu-latest
strategy:
matrix:
project:
- name: 'App.Function.Banktransaction.Import'
service: 'function-banktransaction-import'
dotnet-version: '6.0'
steps:
- uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v2
- run: |
test -d ${{ matrix.project.name }}/terraform || exit 0
cd ${{ matrix.project.name }}/terraform
terraform init
terraform validate
test_integration:
test_unit:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ bin/
obj/
/packages/
riderModule.iml
terraform.tfstate
.terraform/
/_ReSharper.Caches/
/.idea
8 changes: 0 additions & 8 deletions App.Function.Banktransaction.Import/queue.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions App.Function.Banktransaction.Import/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions App.Function.Banktransaction.Import/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variable "environment" {
type = string
}

variable "cloudrun_url" {
type = string
}

terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.40.0"
}
}
}

provider "google" {}

resource "google_pubsub_topic" "bankstransaction-import" {
name = "bankstransaction-import-${var.environment}"
}

resource "google_pubsub_subscription" "bankstransaction-import" {
name = "function-bankstransaction-import-${var.environment}"
topic = google_pubsub_topic.bankstransaction-import.name

push_config {
push_endpoint = var.cloudrun_url
}
}

0 comments on commit 366789a

Please sign in to comment.