Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OLH-1717 Set nvmrc version based on Dockerfile #1451

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/update-dependabot-nvmrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Update Dependabot PRs

on:
pull_request:
branches:
- 'dependabot/**'
workflow_dispatch:

jobs:
update:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # pin@v4.1.7
- name: Set up git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Extract Node.js version from Dockerfile
id: extract_version
run: |
VERSION=$(grep -m 1 -oP 'FROM node:\K[0-9]+\.[0-9]+\.[0-9]+' Dockerfile)
VERSION=$(echo $VERSION | tr -d '\n\r')
echo "NODE_VERSION=$VERSION" >> $GITHUB_ENV

- name: Read current .nvmrc version
id: read_nvmrc
run: |
if [ -f .nvmrc ]; then
CURRENT_VERSION=$(cat .nvmrc | tr -d '\n\r')
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
else
echo "CURRENT_VERSION=" >> $GITHUB_ENV
fi

- name: Check if versions are different
id: check_diff
run: |
if [ "$NODE_VERSION" = "$CURRENT_VERSION" ]; then
echo "Versions are the same. No update needed."
echo "create_pr=false" >> $GITHUB_ENV
else
echo "Versions are different. Update needed."
echo "create_pr=true" >> $GITHUB_ENV
fi

- name: Update .nvmrc if update is needed
if: env.create_pr == 'true'
run: |
echo "$NODE_VERSION" > .nvmrc
git add .nvmrc
git commit -m "Updated .nvmrc"
git push
Loading