From 4a0bf52456c4e1bf1f42d7c358f1334eb3d35e18 Mon Sep 17 00:00:00 2001 From: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:13:26 +0100 Subject: [PATCH] Enabling cron running Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com> --- .github/workflows/index-manual.yml | 6 +++++- .github/workflows/index.yml | 23 ++++++++++++++++------- search/pg-indexer/main.go | 8 +++----- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/.github/workflows/index-manual.yml b/.github/workflows/index-manual.yml index 86e11114..6c1a4c61 100644 --- a/.github/workflows/index-manual.yml +++ b/.github/workflows/index-manual.yml @@ -41,6 +41,10 @@ jobs: with: path: ./backend/internal/moduleindex/moduleschema/testtofu key: tofu-binary + - name: Build tofu + working-directory: backend + run: + go generate ./... - name: Run generation working-directory: backend env: @@ -51,7 +55,7 @@ jobs: NAMESPACE: ${{inputs.namespace}} NAME: ${{inputs.name}} TARGET_SYSTEM: ${{inputs.target_system}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} FORCE_REGENERATE: ${{inputs.force_regenerate}} run: | - go generate ./... go run github.com/opentofu/registry-ui/cmd/generate --log-level=trace --s3-bucket=${S3_BUCKET} --blocklist ../blocklist.json --licenses-file ../licenses.json --namespace="${NAMESPACE}" --name="${NAME}" --target-system="${TARGET_SYSTEM}" --force-regenerate="${FORCE_REGENERATE}" diff --git a/.github/workflows/index.yml b/.github/workflows/index.yml index af71fb99..6d21023b 100644 --- a/.github/workflows/index.yml +++ b/.github/workflows/index.yml @@ -1,4 +1,4 @@ -name: Index +name: Index (cron) permissions: {} on: schedule: @@ -13,6 +13,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + with: + ref: main - name: Setup go uses: actions/setup-go@v5 with: @@ -22,16 +24,23 @@ jobs: with: path: ./backend/internal/moduleindex/moduleschema/testtofu key: tofu-binary - - name: Run generation + - name: Build tofu + working-directory: backend + run: + go generate ./... + - name: Update documentation working-directory: backend env: AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}} AWS_ENDPOINT_URL_S3: ${{secrets.AWS_ENDPOINT_URL_S3}} AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}} S3_BUCKET: ${{secrets.S3_BUCKET}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} NAMESPACES: hashicorp opentofu env0 spacelift-io scalr harness-io integrations - run: | - go generate ./... - for NAMESPACE in ${NAMESPACES}; do - go run github.com/opentofu/registry-ui/cmd/generate --log-level=trace --namespace="${NAMESPACE}" --s3-bucket=${S3_BUCKET} --blocklist ../blocklist.json --licenses-file ../licenses.json - done + run: + go run github.com/opentofu/registry-ui/cmd/generate --log-level=trace --s3-bucket=${S3_BUCKET} --blocklist ../blocklist.json --licenses-file ../licenses.json + - name: Update search index + working-directory: search/pg-indexer + env: + PG_CONNECTION_STRING: ${{secrets.PG_CONNECTION_STRING}} + run: go run ./ diff --git a/search/pg-indexer/main.go b/search/pg-indexer/main.go index cfca2ad6..8f1d8d68 100644 --- a/search/pg-indexer/main.go +++ b/search/pg-indexer/main.go @@ -18,19 +18,17 @@ import ( ) func main() { - var connString string - flag.StringVar(&connString, "connection-string", "", "Postgres connection string") - + connString := os.Getenv("PG_CONNECTION_STRING") var batchSize int flag.IntVar(&batchSize, "batch-size", 1000, "Batch size for inserts") flag.Parse() if connString == "" { - log.Fatal("connection string is required") + log.Fatal("Please set the PG_CONNECTION_STRING environment variable.") } if batchSize <= 0 { - log.Fatal("batch size must be greater than 0") + log.Fatal("The batch size must be greater than 0.") } body, err := downloadSearchMetaIndex()