Skip to content

Commit

Permalink
Merge pull request #253 from opentofu/cron
Browse files Browse the repository at this point in the history
Enabling cron running
  • Loading branch information
abstractionfactory authored Nov 28, 2024
2 parents 5963197 + 4a0bf52 commit b8e9f78
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/index-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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}"
23 changes: 16 additions & 7 deletions .github/workflows/index.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Index
name: Index (cron)
permissions: {}
on:
schedule:
Expand All @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Setup go
uses: actions/setup-go@v5
with:
Expand All @@ -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 ./
8 changes: 3 additions & 5 deletions search/pg-indexer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b8e9f78

Please sign in to comment.