@samitouri / QOS-React-2 / commits / 85f489a129

Add publish workflow, triggerable via API request (#20726)

Adds a new CircleCI workflow, which I will use to publish prereleases (`next` and `experimental`) for a given commit. The CircleCI API doesn't yet support triggering a specific workflow, but it does support triggering a pipeline. So as a workaround you can triggger the entire pipeline and use parameters to disable everything except the workflow you want. CircleCI recommends this workaround here: https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2- Eventually we can set this workflow to trigger on a cron schedule (once per week, for example).

Andrew Clark committed Feb 3, 2021 at 14:17 UTC 85f489a12963edf44a0892ad12cbf7fb4dfbe9ea
1 file changed +49
.circleci/config.yml
+49
@@ -23,6 +23,17 @@ aliases:
23 - &attach_workspace
24 at: build
25
26 +# The CircleCI API doesn't yet support triggering a specific workflow, but it
27 +# does support triggering a pipeline. So as a workaround you can triggger the
28 +# entire pipeline and use parameters to disable everything except the workflow
29 +# you want. CircleCI recommends this workaround here:
30 +# https://support.circleci.com/hc/en-us/articles/360050351292-How-to-trigger-a-workflow-via-CircleCI-API-v2-
31 +parameters:
32 + # This is only set when triggering the CI pipeline via an API request.
33 + prerelease_commit_sha:
34 + type: string
35 + default: ''
36 +
37 jobs:
38 setup:
39 docker: *docker
@@ -341,9 +352,27 @@ jobs:
352 FUZZ_TEST_SEED=$RANDOM yarn test fuzz --ci
353 FUZZ_TEST_SEED=$RANDOM yarn test --prod fuzz --ci
354
355 + publish_prerelease:
356 + parameters:
357 + commit_sha:
358 + type: string
359 + release_channel:
360 + type: string
361 + docker: *docker
362 + environment: *environment
363 + steps:
364 + - checkout
365 + - run: yarn workspaces info | head -n -1 > workspace_info.txt
366 + - *restore_node_modules
367 + # TODO: This doesn't actually publish anything yet. Just logs the inputs.
368 + - run: |
369 + echo "<< parameters.commit_sha >>"
370 + echo "<< parameters.release_channel >>"
371 +
372 workflows:
373 version: 2
374 stable:
375 + unless: << pipeline.parameters.prerelease_commit_sha >>
376 jobs:
377 - setup
378 - yarn_lint:
@@ -363,6 +392,7 @@ workflows:
392 - RELEASE_CHANNEL_stable_yarn_build
393
394 experimental:
395 + unless: << pipeline.parameters.prerelease_commit_sha >>
396 jobs:
397 - setup
398 - yarn_build:
@@ -387,6 +417,7 @@ workflows:
417
418 # New workflow that will replace "stable" and "experimental"
419 build_and_test:
420 + unless: << pipeline.parameters.prerelease_commit_sha >>
421 jobs:
422 - setup
423 - yarn_test:
@@ -463,6 +494,7 @@ workflows:
494 - get_base_build
495 - yarn_build_combined
496 fuzz_tests:
497 + unless: << pipeline.parameters.prerelease_commit_sha >>
498 triggers:
499 - schedule:
500 # Fuzz tests run hourly
@@ -476,3 +508,20 @@ workflows:
508 - test_fuzz:
509 requires:
510 - setup
511 +
512 + # TODO: This workflow doesn't do anything yet, but you should be able to
513 + # trigger it using the CircleCI API
514 + publish_preleases:
515 + when: << pipeline.parameters.prerelease_commit_sha >>
516 + jobs:
517 + - setup
518 + - publish_prerelease:
519 + requires:
520 + - setup
521 + matrix:
522 + parameters:
523 + commit_sha:
524 + - << pipeline.parameters.prerelease_commit_sha >>
525 + release_channel:
526 + - stable
527 + - experimental