|
| 1 | +name: Update DevCycle SDK to Latest |
| 2 | +on: |
| 3 | + schedule: |
| 4 | + - cron: "0 12 * * *" |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +jobs: |
| 8 | + update-dvc: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v4 |
| 12 | + with: |
| 13 | + fetch-depth: 0 |
| 14 | + - uses: actions/setup-node@v3 |
| 15 | + with: |
| 16 | + node-version: '20.x' |
| 17 | + cache: 'yarn' |
| 18 | + |
| 19 | + - name: Set Git author |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + git config --global user.email "[email protected]" |
| 23 | + git config --global user.name "DevCycle Automation" |
| 24 | +
|
| 25 | + - name: Set branch name |
| 26 | + shell: bash |
| 27 | + run: echo "BRANCH_NAME=update-dvc-sdk" >> $GITHUB_ENV |
| 28 | + |
| 29 | + - name: Update @devcycle/js-client-sdk to latest |
| 30 | + run: yarn add @devcycle/js-client-sdk@latest |
| 31 | + |
| 32 | + - name: Check for changes to package.json |
| 33 | + run: echo "IS_UPDATED=$(git diff --name-only origin/main package.json)" >> $GITHUB_ENV |
| 34 | + |
| 35 | + - name: Check if branch already exists |
| 36 | + run: echo "BRANCH_EXISTS=$(git branch -a | grep $BRANCH_NAME)" >> $GITHUB_ENV |
| 37 | + |
| 38 | + - name: Commit & push changes |
| 39 | + if: ${{ env.IS_UPDATED && !env.BRANCH_EXISTS }} |
| 40 | + shell: bash |
| 41 | + run: | |
| 42 | + git checkout -b "$BRANCH_NAME" |
| 43 | + git add package.json |
| 44 | + git add yarn.lock |
| 45 | + git commit -m "Update @devcycle/js-client-sdk to latest" |
| 46 | + git push --set-upstream origin "$BRANCH_NAME" |
| 47 | +
|
| 48 | + - name: Create Pull Request |
| 49 | + if: ${{ env.IS_UPDATED && !env.BRANCH_EXISTS }} |
| 50 | + shell: bash |
| 51 | + env: |
| 52 | + GH_TOKEN: ${{ secrets.AUTOMATION_USER_TOKEN }} |
| 53 | + run: | |
| 54 | + gh pr create \ |
| 55 | + --base main --head "$BRANCH_NAME" \ |
| 56 | + --title "chore(deps): Update @devcycle/js-client-sdk to latest" \ |
| 57 | + --body "This PR is auto generated by this [github workflow](https://github.com/${{ github.repository }}/actions/workflows/update-dvc-sdk.yml)" \ |
| 58 | + --reviewer DevCycleHQ-Sandbox/engineering |
0 commit comments