Update DevCycle SDKs to Latest #288
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 DevCycle SDKs to Latest | |
on: | |
schedule: | |
- cron: "0 12 * * *" | |
workflow_dispatch: | |
jobs: | |
update-dvc: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
cache: 'yarn' | |
- name: Set Git author | |
shell: bash | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "DevCycle Automation" | |
- name: Set branch name | |
shell: bash | |
run: echo "BRANCH_NAME=update-of-sdk" >> $GITHUB_ENV | |
- name: Update OpenFeature SDKs to latest | |
run: yarn add @openfeature/core @openfeature/server-sdk @openfeature/web-sdk | |
- name: Update @openfeature/server-sdk peerDependencies in sdk/nodejs/package.json | |
working-directory: sdk/nodejs | |
run: yarn add --peer @openfeature/server-sdk | |
- name: Update @openfeature/web-sdk peerDependencies in sdk/openfeature-web-provider/package.json | |
working-directory: sdk/openfeature-web-provider | |
run: yarn add --peer @openfeature/web-sdk | |
- name: Check for changes to package.json | |
shell: bash | |
run: | | |
IS_UPDATED=$(git diff --name-only origin/main package.json sdk/nodejs/package.json sdk/openfeature-web-provider/package.json | wc -l) | |
if [ "$IS_UPDATED" -gt "0" ]; then | |
echo "IS_UPDATED=true" >> $GITHUB_ENV | |
else | |
echo "IS_UPDATED=false" >> $GITHUB_ENV | |
fi | |
- name: Check if branch already exists | |
run: echo "BRANCH_EXISTS=$(git branch -a | grep $BRANCH_NAME)" >> $GITHUB_ENV | |
- name: Commit & push changes | |
if: ${{ env.IS_UPDATED && !env.BRANCH_EXISTS }} | |
shell: bash | |
run: | | |
git checkout -b "$BRANCH_NAME" | |
git add package.json | |
git add sdk/nodejs/package.json | |
git add sdk/openfeature-web-provider/package.json | |
git add yarn.lock | |
git commit -m "Update OpenFeature SDKs to latest" | |
git push --set-upstream origin "$BRANCH_NAME" | |
- name: Create Pull Request | |
if: ${{ env.IS_UPDATED && !env.BRANCH_EXISTS }} | |
shell: bash | |
env: | |
GH_TOKEN: ${{ secrets.AUTOMATION_USER_TOKEN }} | |
run: | | |
gh pr create \ | |
--base main --head "$BRANCH_NAME" \ | |
--title "chore(deps): Update OpenFeature SDKs to latest" \ | |
--body "This PR is auto generated by this [github workflow](https://github.com/${{ github.repository }}/actions/workflows/update-of-sdk.yml)" \ | |
--reviewer DevCycleHQ/engineering |