Skip to content

(v9) Update react-charts package #68

(v9) Update react-charts package

(v9) Update react-charts package #68

name: (v9) Update react-charts package
on:
schedule:
- cron: "30 5 * * *" # Runs every day at 11:00 AM IST (05:30 AM UTC)
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-react-charts:
runs-on: ubuntu-latest
steps:
- name: Enable Git long paths
run: git config --global core.longpaths true
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Get latest @fluentui/react-charts version
shell: bash
id: get_latest_version
run: |
echo "version=$(npm view @fluentui/react-charts versions --json | jq -r '.[]' | grep nightly | tail -n 1)" >> $GITHUB_OUTPUT
- name: Ensure jq is installed
run: |
if ! command -v jq &> /dev/null
then
sudo apt-get update
sudo apt-get install -y jq
fi
- name: Get current @fluentui/react-charts version
id: get_current_version
run: |
cd apps/plotly_examples
version=$(jq -r '.dependencies["@fluentui/react-charts"]' package.json | sed 's/^[~^]//')
echo "current_version=$version" >> $GITHUB_OUTPUT
- name: Check if update is needed
id: check_update
run: |
echo "Current: ${{ steps.get_current_version.outputs.current_version }}"
echo "Latest: ${{ steps.get_latest_version.outputs.version }}"
if [ "${{ steps.get_current_version.outputs.current_version }}" = "${{ steps.get_latest_version.outputs.version }}" ]; then
echo "up_to_date=true" >> $GITHUB_OUTPUT
else
echo "up_to_date=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Update package.json with latest version
if: steps.check_update.outputs.up_to_date == 'false'
run: |
cd apps/plotly_examples
npm pkg set dependencies.@fluentui/react-charts="${{ steps.get_latest_version.outputs.version }}"
- name: Install dependencies
if: steps.check_update.outputs.up_to_date == 'false'
run: |
cd apps/plotly_examples
yarn install
- name: Update version in App.tsx for nightly build
if: steps.check_update.outputs.up_to_date == 'false'
run: |
cd apps/plotly_examples/src
# Extract just the version number (e.g., 0.0.0-nightly-20250603-0406.1) from the latest version
version="${{ steps.get_latest_version.outputs.version }}"
# Use sed to replace with the new version
sed -i -E "s/0\.0\.0-nightly-20[0-9]{6}-[0-9]{4}\.[0-9]+/$version/g" App.tsx
git add App.tsx
- name: Build app after updating version
if: steps.check_update.outputs.up_to_date == 'false'
run: |
cd apps/plotly_examples
yarn build
- name: Create branch name with updated package version
if: steps.check_update.outputs.up_to_date == 'false'
id: branch
run: |
BRANCH="update-react-charts-${{ steps.get_latest_version.outputs.version }}"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
- name: Commit changes to repo
id: auto-commit-action
uses: stefanzweifel/git-auto-commit-action@v5
if: steps.check_update.outputs.up_to_date == 'false'
with:
branch: ${{ steps.branch.outputs.branch }}
create_branch: true
commit_message: (chore) (auto) update @fluentui/react-charts to version ${{ steps.get_latest_version.outputs.version }}
- name: "Publish Notification regarding changes"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
shell: bash
run: |
echo "Create a pull request using this link: https://www.github.com/microsoft/fluentui-charting-contrib/pull/new/$${{ steps.branch.outputs.branch }}" >> $GITHUB_STEP_SUMMARY