diff --git a/.github/workflows/dbac-deploy.yaml b/.github/workflows/dbac-deploy.yaml new file mode 100644 index 0000000..475ec3c --- /dev/null +++ b/.github/workflows/dbac-deploy.yaml @@ -0,0 +1,102 @@ +name: DbaC Deploy + +on: + workflow_dispatch: + + pull_request: + branches: + - main + + # paths: + # - 'versions.tf' + # - 'provider.tf' + # - 'tfvars/wsl.tfvars' + # - 'entrypoint.tf' + # - 'modules/**' + # - .github/workflows/dbac-deploy.yaml + + # workflow_run: + # workflows: ["Generate terraform docs"] # Name of the tf-docs.yaml workflow + # types: + # - completed + # branches: + # - main + +env: + # Set the default postgresql user admin password: + TF_VAR_postgresql_default_password: ${{ secrets.POSTGRES_USER_DEFAULT_PASSWORD }} + +jobs: + + docs: + runs-on: ubuntu-latest + + permissions: + contents: 'write' + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} # Use the PR branch for checkout + + - name: Render terraform docs inside the README.md and push changes back to PR branch + uses: terraform-docs/gh-actions@v1.4.1 + with: + working-dir: . + output-file: README.md + output-method: inject + git-push: "true" + + dbac_deploy: + name: 'dbac deploy' + runs-on: DbaC + needs: [docs] + + defaults: + run: + working-directory: './' + + permissions: + contents: 'read' + id-token: 'write' + + steps: + # Checkout the repository to the GitHub Actions runner + - name: Checkout + uses: 'actions/checkout@v4' + + # Install Node.js + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' # Use the appropriate version of Node.js + + # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token + - name: "Setup Terraform" + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "1.9.0" + + # Checks that all Terraform configuration files adhere to a canonical format + - name: "Terraform Format" + id: fmt + run: terraform fmt + continue-on-error: false + + # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. + - name: "Terraform Initialize" + id: init + run: | + terraform init -backend-config="backends/wsl.hcl" -input=false + continue-on-error: false + + # Generates an execution plan for Terraform + - name: "Terraform Plan" + id: plan + run: terraform plan -var-file tfvars/wsl.tfvars -refresh=true -input=false -lock=false -no-color + continue-on-error: false + + - name: "Terraform Apply" + id: apply + if: steps.plan.outcome == 'success' + run: terraform apply -var-file tfvars/wsl.tfvars -input=false -lock=false -auto-approve -no-color \ No newline at end of file diff --git a/.github/workflows/tf-docs.yaml b/.github/workflows/tf-docs.yaml deleted file mode 100644 index 73ee4c5..0000000 --- a/.github/workflows/tf-docs.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: Generate terraform docs -on: - pull_request: - branches: - - main - - workflow_dispatch: - -jobs: - docs: - runs-on: ubuntu-latest - - permissions: - contents: 'write' - - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ github.event.pull_request.head.ref }} # Use the PR branch for checkout - - - name: Render terraform docs inside the README.md and push changes back to PR branch - uses: terraform-docs/gh-actions@v1.4.1 - with: - working-dir: . - output-file: README.md - output-method: inject - git-push: "true" \ No newline at end of file diff --git a/modules/README.md b/modules/README.md deleted file mode 100644 index ef2fa69..0000000 --- a/modules/README.md +++ /dev/null @@ -1,25 +0,0 @@ - -## Requirements - -No requirements. - -## Providers - -No providers. - -## Modules - -No modules. - -## Resources - -No resources. - -## Inputs - -No inputs. - -## Outputs - -No outputs. - \ No newline at end of file diff --git a/modules/database/README.md b/modules/database/README.md deleted file mode 100644 index a097575..0000000 --- a/modules/database/README.md +++ /dev/null @@ -1,31 +0,0 @@ - -## Requirements - -No requirements. - -## Providers - -| Name | Version | -|------|---------| -| [postgresql.wsl](#provider\_postgresql.wsl) | n/a | - -## Modules - -No modules. - -## Resources - -| Name | Type | -|------|------| -| [postgresql_database.example_db](https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs/resources/database) | resource | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [postgresql\_databases](#input\_postgresql\_databases) | A map of PostgreSQL databases to create |
map(object({
name = string
db_owner = string
}))
| `{}` | no | - -## Outputs - -No outputs. - \ No newline at end of file