From 534e15e5c070c9dc1066c75e879b84a124bc6750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Thu, 29 Aug 2024 16:22:50 +0200 Subject: [PATCH 1/5] Add websites and READMEs --- main.tf | 116 +++++++++++++++---------- modules/pubsub_repo/README.template.md | 39 +++++++++ modules/pubsub_repo/main.tf | 19 +++- modules/pubsub_repo/vars.tf | 8 +- 4 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 modules/pubsub_repo/README.template.md diff --git a/main.tf b/main.tf index 299ee70..4792541 100644 --- a/main.tf +++ b/main.tf @@ -17,98 +17,126 @@ provider "github" { module "pubsub_repo_amazonsqs" { source = "./modules/pubsub_repo" - id = "amazonsqs" - name = "Amazon SQS/SNS" - description = "" - url = "" + id = "amazonsqs" + name = "Amazon SQS/SNS" + + details = < + +[![CI Status](https://github.com/ThreeDotsLabs/watermill-${id}/actions/workflows/master.yml/badge.svg)](https://github.com/ThreeDotsLabs/watermill-${id}/actions/workflows/master.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/ThreeDotsLabs/watermill-${id})](https://goreportcard.com/report/github.com/ThreeDotsLabs/watermill-${id}) + +This is Pub/Sub for the [Watermill](https://watermill.io/) project. +${details} + +## Watermill + +Watermill is a Go library for working efficiently with message streams. It is intended +for building event driven applications, enabling event sourcing, RPC over messages, +sagas and basically whatever else comes to your mind. You can use conventional pub/sub +implementations like Kafka or RabbitMQ, but also HTTP or MySQL binlog if that fits your use case. + +All Pub/Sub implementations can be found at [https://watermill.io/pubsubs/](https://watermill.io/pubsubs/). + +Documentation: https://watermill.io/ + +Getting started guide: https://watermill.io/docs/getting-started/ + +Issues: https://github.com/ThreeDotsLabs/watermill/issues + +## Contributing + +All contributions are very much welcome. If you'd like to help with Watermill development, +please see [open issues](https://github.com/ThreeDotsLabs/watermill/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+) +and submit your pull request via GitHub. + +## Support + +If you didn't find the answer to your question in [the documentation](https://watermill.io/), feel free to ask us directly! + +Please join us on the `#watermill` channel on the [Three Dots Labs Discord](https://discord.gg/QV6VFg4YQE). + +## License + +[MIT License](./LICENSE) diff --git a/modules/pubsub_repo/main.tf b/modules/pubsub_repo/main.tf index db31023..848fc20 100644 --- a/modules/pubsub_repo/main.tf +++ b/modules/pubsub_repo/main.tf @@ -15,7 +15,7 @@ resource "github_repository" "repo" { name = "watermill-${var.id}" description = "${var.name} Pub/Sub for the Watermill project." - homepage_url = var.url + homepage_url = "https://watermill.io/pubsubs/${var.id}/" has_downloads = true has_issues = false @@ -33,3 +33,20 @@ resource "github_repository" "repo" { vulnerability_alerts = true } + +resource "github_branch_default" "master" { + repository = github_repository.repo.name + branch = var.default_branch +} + +resource "github_repository_file" "readme" { + repository = github_repository.repo.name + branch = github_branch_default.master.branch + file = "README.md" + content = templatefile("${path.module}/README.template.md", { + id = var.id + name = var.name + }) + commit_message = "Update README.md (by Terraform)" + overwrite_on_create = true +} diff --git a/modules/pubsub_repo/vars.tf b/modules/pubsub_repo/vars.tf index 115a767..2f8e4ad 100644 --- a/modules/pubsub_repo/vars.tf +++ b/modules/pubsub_repo/vars.tf @@ -1,4 +1,8 @@ variable "id" {} variable "name" {} -variable "description" {} -variable "url" {} +variable "default_branch" { + default = "master" +} +variable "details" { + default = "" +} From 1c0e6b1989c5d253121f311161cd3e8472edb90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Thu, 29 Aug 2024 16:25:16 +0200 Subject: [PATCH 2/5] Show errors --- .github/workflows/pr.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 77aca51..4562d04 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,6 +34,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.TERRAFORM_GITHUB_TOKEN }} GOOGLE_APPLICATION_CREDENTIALS: credentials.json + - run: cat plan_errors + if: steps.plan.outcome != 'success' + - run: terraform show -no-color out.tfplan | tee plan - uses: actions/github-script@v7 From f6003ee01bc0196ee698b92ec268d3850f052957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Thu, 29 Aug 2024 16:27:22 +0200 Subject: [PATCH 3/5] . --- .github/workflows/pr.yml | 3 --- modules/pubsub_repo/main.tf | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4562d04..77aca51 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -34,9 +34,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.TERRAFORM_GITHUB_TOKEN }} GOOGLE_APPLICATION_CREDENTIALS: credentials.json - - run: cat plan_errors - if: steps.plan.outcome != 'success' - - run: terraform show -no-color out.tfplan | tee plan - uses: actions/github-script@v7 diff --git a/modules/pubsub_repo/main.tf b/modules/pubsub_repo/main.tf index 848fc20..0193e0a 100644 --- a/modules/pubsub_repo/main.tf +++ b/modules/pubsub_repo/main.tf @@ -44,8 +44,9 @@ resource "github_repository_file" "readme" { branch = github_branch_default.master.branch file = "README.md" content = templatefile("${path.module}/README.template.md", { - id = var.id - name = var.name + id = var.id + name = var.name + details = var.details }) commit_message = "Update README.md (by Terraform)" overwrite_on_create = true From 12ea839bf12f19889e09b0fd0f1a05389b4c5d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Sm=C3=B3=C5=82ka?= Date: Fri, 30 Aug 2024 10:54:50 +0200 Subject: [PATCH 4/5] Update --- main.tf | 43 ++------------------------ modules/pubsub_repo/README.template.md | 2 +- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/main.tf b/main.tf index 4792541..3b584d5 100644 --- a/main.tf +++ b/main.tf @@ -20,9 +20,7 @@ module "pubsub_repo_amazonsqs" { id = "amazonsqs" name = "Amazon SQS/SNS" - details = < Date: Fri, 30 Aug 2024 15:16:04 +0200 Subject: [PATCH 5/5] CHange CI --- .github/workflows/master.yml | 55 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index d93f63e..3fcebe5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -6,7 +6,7 @@ on: - master jobs: - apply: + plan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -19,25 +19,25 @@ jobs: env: CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} - - id: fmt - run: terraform fmt -check - continue-on-error: true + - run: terraform fmt -check - - id: init - run: terraform init + - run: terraform init env: GOOGLE_APPLICATION_CREDENTIALS: credentials.json - - id: validate - run: terraform validate -no-color | tee validation + - run: terraform validate -no-color - - id: plan - run: terraform plan -out=out.tfplan -no-color -input=false 2> plan_errors + - run: terraform plan -out=out.tfplan -no-color -input=false continue-on-error: true env: GITHUB_TOKEN: ${{ secrets.TERRAFORM_GITHUB_TOKEN }} GOOGLE_APPLICATION_CREDENTIALS: credentials.json + - uses: actions/upload-artifact@v4 + with: + name: out.tfplan + path: out.tfplan + - run: | TMP_OUTPUT=$(terraform show -no-color out.tfplan) FORMATTED_OUTPUT="${TMP_OUTPUT:0:65536}" @@ -46,22 +46,35 @@ jobs: - id: output run: | { - echo 'PLAN_OUTPUT<> "$GITHUB_OUTPUT" + } >> "$GITHUB_STEP_SUMMARY" + + apply: + needs: plan + environment: production + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.9.5 + terraform_wrapper: false + + - run: echo -n "$CREDENTIALS" > credentials.json + env: + CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + + - id: init + run: terraform init + env: + GOOGLE_APPLICATION_CREDENTIALS: credentials.json - - name: Approve - uses: trstringer/manual-approval@v1.9.1 - timeout-minutes: 5 + - uses: actions/download-artifact@v4 with: - issue-title: "Terraform changes require approval" - secret: ${{ github.TOKEN }} - approvers: m110,roblaszczak - issue-body: ${{ steps.output.outputs.PLAN_OUTPUT }} - minimum-approvals: 1 + name: out.tfplan - name: Apply run: terraform apply out.tfplan