From 32747ca4049d556742a963a7340ad43b81e06f66 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Fri, 4 Oct 2024 10:08:34 -0400 Subject: [PATCH] add workflow for generating floor locations --- .github/workflows/update_floor_locations.yml | 33 +++++++++++++++++++ .../bin/generate_floor_locations_map.rb | 15 +++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/update_floor_locations.yml create mode 100755 umich_catalog_indexing/bin/generate_floor_locations_map.rb diff --git a/.github/workflows/update_floor_locations.yml b/.github/workflows/update_floor_locations.yml new file mode 100644 index 00000000..524d05a2 --- /dev/null +++ b/.github/workflows/update_floor_locations.yml @@ -0,0 +1,33 @@ +name: Update Floor Locations Translation map + +on: + workflow_dispatch: + schedule: + - cron: '0 8 1 * *' #8AM first of the month + +jobs: + update-floor-locations: + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/umich_catalog_indexing/Gemfile + steps: + - uses: actions/checkout@v3 + - name: Set up ruby 3.2 + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.2" + bundler-cache: true + - name: Fetch Translation map + working-directory: ./umich_catalog_indexing + env: + FLOOR_LOCATION_SPREADSHEET_ID: ${{ vars.FLOOR_LOCATION_SPREADSHEET_ID }} + GOOGLE_API_CREDENTIALS: ${{ secrets.GOOGLE_API_CREDENTIALS }} + run: bundle exec ruby bin/generate_floor_locations_map.rb --force + - name: Get PR title + run: echo "PR_TITLE=$(date +'%B %Y') floor location translation map update" >> $GITHUB_ENV + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "config: update floor locations translation map" + title: ${{ env.PR_TITLE }} + reviewers: niquerio diff --git a/umich_catalog_indexing/bin/generate_floor_locations_map.rb b/umich_catalog_indexing/bin/generate_floor_locations_map.rb new file mode 100755 index 00000000..a8a660a8 --- /dev/null +++ b/umich_catalog_indexing/bin/generate_floor_locations_map.rb @@ -0,0 +1,15 @@ +#!/usr/local/bin/ruby +require "optparse" +require_relative "../lib/sidekiq_jobs" + +force = false +OptionParser.new do |opts| + opts.on("-f", "--force", "Force generation of floor locations translation map even if it is less than one day old") do |x| + force = true if x + end + opts.on("-h", "--help", "Prints this help") do + puts opts + exit + end +end.parse! +Jobs::TranslationMapGenerator.generate(generator: Jobs::TranslationMapGenerator::FloorLocations, force: force)