Update DevCycle SDK to Latest #183
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 SDK 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: 'npm' | |
- 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-dvc-sdk" >> $GITHUB_ENV | |
- name: Update @devcycle/nextjs-sdk to latest | |
run: npm install @devcycle/nextjs-sdk@latest | |
- name: Check for changes to package.json | |
run: echo "IS_UPDATED=$(git diff --name-only origin/main package.json)" >> $GITHUB_ENV | |
- 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 package-lock.json | |
git commit -m "Update @devcycle/nextjs-sdk 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 @devcycle/nextjs-sdk to latest" \ | |
--body "This PR is auto generated by this [github workflow](https://github.com/${{ github.repository }}/actions/workflows/update-dvc-sdk.yml)" \ | |
--reviewer DevCycleHQ-Labs/engineering |