|
| 1 | +name: OpenMRS CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main, 'patch/*'] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + release: |
| 9 | + types: |
| 10 | + - created |
| 11 | + |
| 12 | +env: |
| 13 | + TURBO_API: 'http://127.0.0.1:9080' |
| 14 | + TURBO_TOKEN: 'turbo-token' |
| 15 | + TURBO_TEAM: ${{ github.repository_owner }} |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + actions: read |
| 22 | + |
| 23 | + steps: |
| 24 | + - uses: actions/checkout@v4 |
| 25 | + - name: 🟢 Use Node.js |
| 26 | + uses: actions/setup-node@v4 |
| 27 | + with: |
| 28 | + node-version: '20.x' |
| 29 | + cache: 'yarn' |
| 30 | + |
| 31 | + - name: 📦 Install dependencies |
| 32 | + run: yarn install --immutable |
| 33 | + |
| 34 | + - name: 🚀 Setup a local cache server for Turborepo |
| 35 | + uses: felixmosh/turborepo-gh-artifacts@v3 |
| 36 | + with: |
| 37 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + server-token: ${{ env.TURBO_TOKEN }} |
| 39 | + |
| 40 | + - name: 🔍 Run lint, type checks and tests |
| 41 | + run: yarn verify |
| 42 | + |
| 43 | + - name: 🏗️ Run build |
| 44 | + run: yarn turbo run build --color --concurrency=5 |
| 45 | + |
| 46 | + pre_release: |
| 47 | + runs-on: ubuntu-latest |
| 48 | + |
| 49 | + needs: build |
| 50 | + |
| 51 | + if: ${{ github.event_name == 'push' }} |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + fetch-depth: 0 |
| 57 | + - name: 🟢 Use Node.js |
| 58 | + uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: '20.x' |
| 61 | + cache: 'yarn' |
| 62 | + registry-url: 'https://registry.npmjs.org' |
| 63 | + |
| 64 | + - name: 📦 Install dependencies |
| 65 | + run: yarn install --immutable |
| 66 | + |
| 67 | + - name: 🚀 Setup local cache server for Turborepo |
| 68 | + uses: felixmosh/turborepo-gh-artifacts@v3 |
| 69 | + with: |
| 70 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + server-token: ${{ env.TURBO_TOKEN }} |
| 72 | + |
| 73 | + - name: 🏷️ Version (main) |
| 74 | + if: github.ref_name == 'main' |
| 75 | + run: yarn workspaces foreach --all --topological --exclude @openmrs/esm-patient-chart version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}" |
| 76 | + |
| 77 | + - name: 🏷️ Version (patch) |
| 78 | + if: startsWith(github.ref_name, 'patch/') |
| 79 | + run: yarn workspaces foreach --all --topological --exclude @openmrs/esm-patient-chart version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-patch.${{ github.run_number }}" |
| 80 | + |
| 81 | + - name: 🏗️ Build |
| 82 | + run: yarn turbo run build --color --concurrency=5 |
| 83 | + |
| 84 | + - name: 🔧 Configure Git |
| 85 | + run: git config user.email "info@openmrs.org" && git config user.name "OpenMRS CI" |
| 86 | + - name: 💾 Commit changes |
| 87 | + run: git add . && git commit -m "Prerelease version" --no-verify |
| 88 | + |
| 89 | + - name: 📤 Pre-release (main) |
| 90 | + if: github.ref_name == 'main' |
| 91 | + run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:prepublish |
| 92 | + env: |
| 93 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 94 | + |
| 95 | + - name: 📤 Pre-release (patch) |
| 96 | + if: startsWith(github.ref_name, 'patch/') |
| 97 | + run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:prepublish-patch |
| 98 | + env: |
| 99 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
| 100 | + |
| 101 | + - name: 📤 Upload build artifacts |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: packages |
| 105 | + path: | |
| 106 | + packages/**/dist |
| 107 | + overwrite: true |
| 108 | + |
| 109 | + deploy_patient_chart: |
| 110 | + runs-on: ubuntu-latest |
| 111 | + |
| 112 | + needs: pre_release |
| 113 | + |
| 114 | + if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} |
| 115 | + |
| 116 | + steps: |
| 117 | + - name: 🚀 Trigger RefApp Build |
| 118 | + uses: fjogeleit/http-request-action@v1 |
| 119 | + continue-on-error: true |
| 120 | + with: |
| 121 | + url: https://ci.openmrs.org/rest/api/latest/queue/O3-BF |
| 122 | + method: 'POST' |
| 123 | + customHeaders: '{ "Authorization": "Bearer ${{ secrets.BAMBOO_TOKEN }}" }' |
| 124 | + |
| 125 | + release: |
| 126 | + runs-on: ubuntu-latest |
| 127 | + |
| 128 | + needs: build |
| 129 | + |
| 130 | + if: ${{ github.event_name == 'release' }} |
| 131 | + |
| 132 | + steps: |
| 133 | + - uses: actions/checkout@v4 |
| 134 | + - name: 🟢 Use Node.js |
| 135 | + uses: actions/setup-node@v4 |
| 136 | + with: |
| 137 | + node-version: '20.x' |
| 138 | + cache: 'yarn' |
| 139 | + registry-url: 'https://registry.npmjs.org' |
| 140 | + |
| 141 | + - name: 📦 Install dependencies |
| 142 | + run: yarn install --immutable |
| 143 | + |
| 144 | + - name: 🚀 Setup local cache server for Turborepo |
| 145 | + uses: felixmosh/turborepo-gh-artifacts@v3 |
| 146 | + with: |
| 147 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 148 | + server-token: ${{ env.TURBO_TOKEN }} |
| 149 | + |
| 150 | + - name: 🏗️ Build |
| 151 | + run: yarn turbo run build --color --concurrency=5 |
| 152 | + |
| 153 | + - name: 📢 Publish |
| 154 | + run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn run ci:publish |
| 155 | + env: |
| 156 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |
0 commit comments