Skip to content

Commit

Permalink
Merge pull request #48 from mlibrary/update-dependencies-workflow
Browse files Browse the repository at this point in the history
Update dependencies workflow
  • Loading branch information
niquerio authored Jun 7, 2024
2 parents 0be1fcb + 61023ff commit c4c4ead
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 20 deletions.
14 changes: 14 additions & 0 deletions .github/update_dependencies_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Overview

Monthly dependency updates for Get This

## NPM

```
NPM_SUMMARY
```
## Bundler

```
BUNDLER_SUMMARY
```
90 changes: 90 additions & 0 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -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

4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 15 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit c4c4ead

Please sign in to comment.