|
| 1 | +on: |
| 2 | + workflow_dispatch: |
| 3 | + schedule: |
| 4 | + # every hour |
| 5 | + - cron: '30 * * * *' |
| 6 | + |
| 7 | +name: 'Check for OpenMRS Dependency Updates' |
| 8 | + |
| 9 | +jobs: |
| 10 | + check-for-updates: |
| 11 | + name: Check for updates to OpenMRS libraries |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + if: github.repository_owner == 'openmrs' |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + - name: 🟢 Use Node.js |
| 21 | + uses: actions/setup-node@v4 |
| 22 | + with: |
| 23 | + node-version: 20 |
| 24 | + - name: 💾 Cache dependencies |
| 25 | + id: cache |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: '**/node_modules' |
| 29 | + key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} |
| 30 | + - name: 📦 Install dependencies |
| 31 | + if: steps.cache.outputs.cache-hit != 'true' |
| 32 | + run: yarn install --immutable |
| 33 | + - name: ✅ Check for updates |
| 34 | + run: node ./tools/update-openmrs-deps.mjs |
| 35 | + - name: ⬆️ Create PR if necessary |
| 36 | + id: cpr |
| 37 | + uses: peter-evans/create-pull-request@v7 |
| 38 | + with: |
| 39 | + commit-message: '(chore) Update OpenMRS dependencies' |
| 40 | + title: '(chore) Update OpenMRS dependencies' |
| 41 | + body: | |
| 42 | + Update OpenMRS dependencies |
| 43 | + branch: 'chore/update-openmrs-deps' |
| 44 | + author: 'OpenMRS Bot <infrastructure@openmrs.org>' |
| 45 | + token: ${{ secrets.OMRS_BOT_GH_TOKEN }} |
| 46 | + - name: ✅ Auto approve PR |
| 47 | + if: steps.cpr.outputs.pull-request-operation == 'created' || steps.cpr.outputs.pull-request-operation == 'updated' |
| 48 | + run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}" |
| 49 | + env: |
| 50 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + - name: 🔀 Automerge PR |
| 52 | + if: steps.cpr.outputs.pull-request-operation == 'created' || steps.cpr.outputs.pull-request-operation == 'updated' |
| 53 | + run: gh pr merge --auto --squash "${{ steps.cpr.outputs.pull-request-number }}" |
| 54 | + env: |
| 55 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments