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

Update RAMP4 version via github workflow #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-dupe-class-members': 'off', // `no-dupe-class-members` complains when function overloads are used
'prettier/prettier': ['error', { endOfLine: 'auto' }]
'prettier/prettier': ['error', { endOfLine: 'auto' }],
'vue/multi-word-component-names': 'off'
},
parserOptions: {
parser: '@typescript-eslint/parser'
Expand All @@ -21,4 +22,4 @@ module.exports = {
}
}
]
};
};
71 changes: 71 additions & 0 deletions .github/workflows/ramp-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Update RAMP Version and Create PR

on:
workflow_dispatch:
inputs:
ramp_version:
description: "RAMP version to use"
required: true

jobs:
update-and-pr:
name: Update RAMP Version and Create PR
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Create a new branch
run: |
git checkout -b update-ramp-${{ github.event.inputs.ramp_version }}

- name: Update RAMP version in package.json
run: |
echo "Updating RAMP version in package.json..."
jq ".dependencies[\"ramp-pcar\"] = \"${{ github.event.inputs.ramp_version }}\"" package.json > package.tmp.json
mv package.tmp.json package.json
npm install

- name: Modify main.ts based on RAMP version
run: |
echo "Checking if main.ts needs modification..."
VERSION="${{ github.event.inputs.ramp_version }}"
FILE="src/main.ts"

if [ -f "$FILE" ]; then
# Check if the version is <= 4.8.0
if [ "$(printf '%s\n' "$VERSION" "4.8.0" | sort -V | head -n1)" = "$VERSION" ]; then
echo "RAMP version is 4.8.0 or lower. Updating main.ts..."
sed -i 's|import '\''ramp-pcar/dist/ramp.css'\'';|import '\''ramp-pcar/dist/lib/ramp.css'\'';|g' $FILE
# Check if the version is >= 4.9.0
elif [ "$(printf '%s\n' "$VERSION" "4.9.0" | sort -V | head -n1)" = "4.9.0" ]; then
echo "RAMP version is 4.9.0 or higher. Updating main.ts..."
sed -i 's|import '\''ramp-pcar/dist/lib/ramp.css'\'';|import '\''ramp-pcar/dist/ramp.css'\'';|g' $FILE
else
echo "No changes needed for main.ts."
fi
else
echo "main.ts not found. Skipping modification."
fi

- name: Commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json yarn.lock src/main.ts
git commit -m "Update RAMP version to ${{ github.event.inputs.ramp_version }}"
git push origin update-ramp-${{ github.event.inputs.ramp_version }}

- name: Create Pull Request using github-script
uses: actions/github-script@v6
with:
script: |
const pr = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Update RAMP version to ${{ github.event.inputs.ramp_version }}`,
head: `update-ramp-${{ github.event.inputs.ramp_version }}`,
base: 'master',
body: `This pull request updates the RAMP4 version to ${{ github.event.inputs.ramp_version }}.`
});
Loading
Loading