@@ -167,8 +167,9 @@ For CI/CD or scripting, request JSON output:
167167RAILS_ENV=production FORMAT=json bundle exec rake react_on_rails_pro:verify_license
168168```
169169
170- The task exits with a non-zero status when the license is missing, invalid, or expired. It also reports
171- ` renewal_required: true ` in JSON output when the license is expired or expiring within 30 days.
170+ The task exits with a non-zero status when the license is missing, invalid, or expired. For valid but expiring
171+ licenses, it exits 0 but reports ` renewal_required: true ` in JSON output when the license is expiring within 30 days.
172+ Use the app-owned rake task below if you want a non-zero exit for expiring-soon licenses or a custom warning threshold.
172173
173174#### Blocking CI Example
174175
183184 branches : [main]
184185 workflow_dispatch :
185186
187+ permissions :
188+ contents : read
189+
186190jobs :
187191 verify-license :
188192 runs-on : ubuntu-latest
@@ -196,23 +200,30 @@ jobs:
196200 with :
197201 bundler-cache : true
198202
203+ # Add database, credentials, and other app-specific setup required to boot Rails in production.
199204 - name : Verify React on Rails Pro license
200205 run : bundle exec rake react_on_rails_pro:verify_license
201206` ` `
202207
208+ The task depends on the Rails environment. If your production boot requires credentials or services such as
209+ ` RAILS_MASTER_KEY`, `DATABASE_URL`, or database preparation, add those to the workflow before running the task.
210+
203211# ### Advisory CI Example
204212
205213Use an advisory CI check when you want visibility without failing the workflow :
206214
207- ` ` ` ` yaml
215+ ` ` ` yaml
208216# .github/workflows/react-on-rails-pro-license-advisory.yml
209217name: React on Rails Pro License Advisory
210218
211219on:
212220 schedule:
213- - cron: '0 15 * * 1'
221+ - cron: '0 15 * * 1' # Every Monday at 15:00 UTC
214222 workflow_dispatch:
215223
224+ permissions:
225+ contents: read
226+
216227jobs:
217228 verify-license:
218229 runs-on: ubuntu-latest
@@ -226,6 +237,7 @@ jobs:
226237 with:
227238 bundler-cache: true
228239
240+ # Add database, credentials, and other app-specific setup required to boot Rails in production.
229241 - name: Check React on Rails Pro license
230242 run: |
231243 set +e
@@ -236,38 +248,41 @@ jobs:
236248 {
237249 echo "## React on Rails Pro license"
238250 echo
239- echo ' ` ` ` text'
251+ echo " \`\`\ ` text"
240252 echo "$output"
241- echo '```'
253+ echo " \`\`\` "
242254 } >> "$GITHUB_STEP_SUMMARY"
243255
244256 if [ "$status" -ne 0 ]; then
245257 echo "::warning title=React on Rails Pro license::License validation did not pass. See job summary."
246258 fi
247259
248260 exit 0
249- ````
261+ ` ` `
250262
251263Use either CI example in workflows where repository secrets are available, such as trusted branch pushes, scheduled jobs,
252264manual runs, or deployment gates. Pull requests from public forks usually cannot access repository secrets, so these
253265checks would report a missing token there.
254266
255267# ## Monitor License Expiration
256268
257- If your organization wants an app-owned scheduled check with a custom warning threshold, add a wrapper task like this :
269+ If your organization wants an app-owned scheduled check with a custom warning threshold, add a wrapper task like this.
270+ It uses the Pro utility API and treats the built-in 30-day renewal window as the default :
258271
259272` ` ` ruby
260273# lib/tasks/react_on_rails_pro_license.rake
261274namespace :licenses do
262275 desc "Fail if the React on Rails Pro license is invalid, expired, or expiring soon"
263276 task check_react_on_rails_pro: :environment do
264277 threshold_days = Integer(ENV.fetch("DAYS", "30"))
265- info = ReactOnRailsPro::LicenseValidator .license_info
266- status = info.fetch(:status)
278+ info = ReactOnRailsPro::Utils .license_info
279+ status = info.fetch(:status, :unknown )
267280 expiration = info[:expiration]
268- days_remaining = expiration && ((expiration - Time.current ) / 86_400).ceil
281+ days_remaining = expiration && ((expiration - Time.now ) / 86_400).ceil
269282
270- unless status == :valid
283+ if status == :expired
284+ abort "React on Rails Pro license is expired. Renew and update REACT_ON_RAILS_PRO_LICENSE."
285+ elsif status != :valid
271286 abort "React on Rails Pro license is #{status}. Update REACT_ON_RAILS_PRO_LICENSE."
272287 end
273288
0 commit comments