diff --git a/.github/update_dependencies_template.md b/.github/update_dependencies_template.md new file mode 100644 index 0000000..cbb8ccd --- /dev/null +++ b/.github/update_dependencies_template.md @@ -0,0 +1,14 @@ +# Overview + +Monthly dependency updates for Get This + +## NPM + +``` +NPM_SUMMARY +``` +## Bundler + +``` +BUNDLER_SUMMARY +``` diff --git a/.github/workflows/update-dependencies.yaml b/.github/workflows/update-dependencies.yaml new file mode 100644 index 0000000..881d61d --- /dev/null +++ b/.github/workflows/update-dependencies.yaml @@ -0,0 +1,90 @@ +name: Update dependencies + +on: + workflow_dispatch: + schedule: + - cron: '0 8 1 * *' #8AM first of the month + + +jobs: + update: + runs-on: ubuntu-latest + outputs: + sha: ${{ steps.cpr.outputs.pull-request-head-sha }} + steps: + - uses: actions/checkout@v4 + - name: Create .env file + run: cat env.* > .env + - name: Load .env file + uses: xom9ikk/dotenv@v2 + - name: Set up Ruby 3.3 + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + env: + BUNDLE_RUBYGEMS__PKG__GITHUB__COM: ${{ secrets.GITHUB_TOKEN }} + - name: Get gems to update + continue-on-error: true + run: bundle outdated > /tmp/bundle_summary.txt + - name: clean up bundle_summary.txt + run: | + sed -i -n '/^Gem\s.*Current/,$p' /tmp/bundle_summary.txt + cat /tmp/bundle_summary.txt + - name: Update bundler + run: bundle update --bundler + - name: Update gems + run: bundle update + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: '20.x' + - name: get npm summary + continue-on-error: true + run: | + npm install + npm outdated > /tmp/npm_summary.txt + - name: cat pr body + run: cat /tmp/npm_summary.txt + - name: Update node dependencies + run: | + npx -p npm-check-updates ncu -u + npm install + npm list + - name: Run tests + run: bundle exec rspec + - name: generate pr body + run: | + sed $'/BUNDLER_SUMMARY/{r /tmp/bundle_summary.txt\nd}' .github/update_dependencies_template.md > /tmp/pr_body_first.md + sed $'/NPM_SUMMARY/{r /tmp/npm_summary.txt\nd}' /tmp/pr_body_first.md > /tmp/pr_body.md + - name: Get PR title + run: echo "PR_TITLE=$(date +'%B %Y') dependency updates" >> $GITHUB_ENV + - name: Create Pull Request + id: cpr + uses: peter-evans/create-pull-request@v6 + with: + commit-message: "Update dependencies" + title: ${{ env.PR_TITLE }} + body-path: /tmp/pr_body.md + assignees: niquerio, erinesullivan + + build-unstable: + needs: update + name: Build unstable ${{ needs.update.outputs.sha }} + uses: mlibrary/platform-engineering-workflows/.github/workflows/build-unstable.yml@v1 + with: + image_name: ${{ vars.IMAGE_NAME }} + tag: ${{ needs.update.outputs.sha}} + dockerfile: Dockerfile + secrets: inherit + + deploy-unstable: + needs: build-unstable + name: Deploy to workshop + uses: mlibrary/platform-engineering-workflows/.github/workflows/deploy.yml@v1 + with: + image: ${{ needs.build-unstable.outputs.image }} + file: environments/get-this/workshop/web-image.txt + CONFIG_REPO_RW_APP_ID: ${{ vars.CONFIG_REPO_RW_APP_ID }} + CONFIG_REPO_FULL_NAME: ${{ vars.CONFIG_REPO_FULL_NAME }} + secrets: inherit + diff --git a/Dockerfile b/Dockerfile index 9209616..fe50f06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,9 +36,7 @@ FROM development AS production COPY --chown=${UID}:${GID} . /app ENV BUNDLE_WITHOUT development:test -RUN --mount=type=secret,id=github_token,uid=1000 \ - github_token="$(cat /run/secrets/github_token)" \ - && BUNDLE_RUBYGEMS__PKG__GITHUB__COM=${github_token} bundle install +RUN bundle install RUN npm ci diff --git a/Gemfile b/Gemfile index c5a75ed..c5983e6 100644 --- a/Gemfile +++ b/Gemfile @@ -12,9 +12,9 @@ gem "omniauth_openid_connect" gem "sinatra-flash" gem "rackup" -source "https://rubygems.pkg.github.com/mlibrary" do - gem "alma_rest_client", "~> 2.0" -end +gem "alma_rest_client", + git: "https://github.com/mlibrary/alma_rest_client", + tag: "v2.0.0" # In order to get rspec to work for ruby 3.3. Maybe later see if it's still necessary gem "net-smtp", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 29ea8c2..ff0c5dd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,15 @@ +GIT + remote: https://github.com/mlibrary/alma_rest_client + revision: 9606225d82480b6d1568902813ae9018dd8c1acc + tag: v2.0.0 + specs: + alma_rest_client (2.0.0) + activesupport (~> 7.0, >= 4.2) + faraday + faraday-retry + httpx + rexml + GEM remote: https://rubygems.org/ specs: @@ -44,13 +56,13 @@ GEM faraday (>= 1, < 3) faraday-net_http (3.1.0) net-http - faraday-retry (2.2.0) + faraday-retry (2.2.1) faraday (~> 2.0) ffi (1.16.3) hashdiff (1.1.0) hashie (5.0.0) http-2-next (1.0.3) - httpx (1.2.1) + httpx (1.2.5) http-2-next (>= 1.0.3) i18n (1.14.1) concurrent-ruby (~> 1.0) @@ -250,22 +262,12 @@ GEM puma yabeda (~> 0.5) -GEM - remote: https://rubygems.pkg.github.com/mlibrary/ - specs: - alma_rest_client (2.0.0) - activesupport (~> 7.0, >= 4.2) - faraday - faraday-retry - httpx - rexml - PLATFORMS x86_64-linux DEPENDENCIES activesupport - alma_rest_client (~> 2.0)! + alma_rest_client! climate_control faraday-follow_redirects listen diff --git a/env.example b/env.example index 39abcde..3fd3603 100644 --- a/env.example +++ b/env.example @@ -4,4 +4,3 @@ OIDC_CLIENT_ID='YOUR-OIDC-CLIENT-ID' OIDC_ISSUER='https://your-oidc-issuer' WEBLOGIN_ON='false' ACCOUNT_URL='https://account.lib.umich.edu' -BUNDLE_RUBYGEMS__PKG__GITHUB__COM="YOUR GITHUB TOKEN WITH READ PACKAGES"