Update nvmrc #7
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update .nvmrc | |
on: | |
pull_request: | |
paths: | |
- 'Dockerfile' | |
types: [opened, synchronize] | |
jobs: | |
update-nvmrc: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3 # pin@v3 | |
- name: Extract Node.js version from Dockerfile | |
id: extract_version | |
run: | | |
VERSION=$(grep -oP 'FROM node:\K[0-9]+\.[0-9]+\.[0-9]+' Dockerfile) | |
# Ensuring the version is properly formatted for env variable | |
VERSION=$(echo $VERSION | tr -d '\n\r') | |
echo "NODE_VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create a new branch | |
id: create_branch | |
run: | | |
BRANCH_NAME=update-nvmrc-${{ github.sha }} | |
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV | |
git checkout -b $BRANCH_NAME | |
- name: Update .nvmrc | |
run: | | |
echo "$NODE_VERSION" > .nvmrc | |
git add .nvmrc | |
git commit -m "Update .nvmrc to Node.js version $NODE_VERSION" | |
- name: Push changes to new branch | |
env: | |
ACTIONS_PAT: ${{ secrets.DEV_ECR_REPOSITORY }} | |
run: | | |
git remote set-url origin https://github.com/govuk-one-login/di-account-management-frontend.git | |
git push origin $BRANCH_NAME | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@5874ea5902f1f64af5cc21e1112355f468bb9e7a | |
with: | |
token: ${{ secrets.ACTIONS_PAT }} | |
commit-message: Update .nvmrc to Node.js version ${{ env.NODE_VERSION }} | |
branch: ${{ env.BRANCH_NAME }} | |
title: Update .nvmrc to Node.js version ${{ env.NODE_VERSION }} | |
body: This PR updates .nvmrc to Node.js version ${{ env.NODE_VERSION }} | |
base: ${{ github.base_ref }} |