From 585863e8bdc1502754d9fab3f887c855d5967ed8 Mon Sep 17 00:00:00 2001 From: Monique Rio Date: Fri, 7 Jun 2024 13:47:29 -0400 Subject: [PATCH] add update dependencies workflow --- .github/update_dependencies_template.md | 14 ++++ .github/workflows/update-dependencies.yaml | 88 ++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 .github/update_dependencies_template.md create mode 100644 .github/workflows/update-dependencies.yaml diff --git a/.github/update_dependencies_template.md b/.github/update_dependencies_template.md new file mode 100644 index 0000000..888e6b5 --- /dev/null +++ b/.github/update_dependencies_template.md @@ -0,0 +1,14 @@ +# Overview + +Monthly dependency updates for Account + +## 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..a01c3c6 --- /dev/null +++ b/.github/workflows/update-dependencies.yaml @@ -0,0 +1,88 @@ +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 + sed -i -n '/^Gem\s.*Current/,$p' /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/account/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 +