prefapp / action-make-state-repos-dispatches

Action to calculate and dispatch image changes of a service, in multiple state repositories
MIT License
1 stars 0 forks source link

Use summary of images built to filter dispatches and calculate image name and image tag #26

Closed alambike closed 1 month ago

alambike commented 1 month ago

Motivation

After https://github.com/prefapp/firestarter-workflows/issues/93, we should be able to remove the image tag calculation and use the image information obtained from the build_images_results.json artifact, and filtering automatically the dispatches to do.

With this we should:

This would work with any triggered event (workflow_dispatch, release, pull_request, push...) BUT we would need to make some changes:

New Inputs needed (optionals)

alambike commented 1 month ago

It is not possible to obtain the workflow run_id from the check run, so we are going to go for another solution:

The build-xxx should create a specific status check ( Build Docker snapshots, Build Docker pre-releases, Build Docker releases for the commit, with the annotation_url pointing to the workflow run, and the following array in yaml format to locate the builds made:

- flavor: inss-pre
  image_type: snapshots
  build_args:
    MY_API_URL: https://my-url  
  image_repo: 'service/councilbox/rivulet-client'
  image_tag: v1.17.0-myflavour-pre
  registry: myacr1
  version: v1.17.0-pre
  run_id: 1234132112

- flavor: inss-pre
  image_type: snapshots
  build_args:
    MY_API_URL: https://my-url  
  image_repo: 'service/councilbox/rivulet-client'
  image_tag: v1.17.0-myflavour-pre
  registry: myacr2 # <- alternative registry
  version: v1.17.0-pre
  run_id: 1234132112

If we use the FS GitHub app, we can create our own check suite, and a check run containing info about the images built (for human consumption), and as a backup, if we lose the artifact the developer can get the images tags from here and use the image tag parameter to make the dispatch manually

Automatic mode - triggered by workflow_run

In the automatic mode, the make_dispatches is triggered by an trigger_dispatch_on.. workflow, after a workflow_run event, so we would have direct access to the run id. We need to download, from the trigger_dispatch_on... workflows, the related artifact attached to the workflow_run and build a matrix to make as many dispatches as flavors have been built

Manual dispatch

In the manual dispatch, where the make_dispatches doesn't have direct access to the build-images run_id, we need to:

  1. Locate the commits according to the version input, or the $latest_release, $latest_prerelease, $branch_xxx keywords configured in the config file, related to the flavors to dispatch
  2. Once the commit is found, check the successful checks-run named "Build Docker snapshots" or "Build Docker releases", or "Build Docker pre-releases", that match with the flavors to dispatch
  3. Parse the check-run data to get the image-tag to dispatch, and check if has been uploaded to the corresponding registry