How to get the selected items (with VBO) in the buildConfigurationForm of a custom Action
Provided you use the Views Bulk Operations contrib module, you can use code similar to the following, inside the buildConfigurationForm() method. Most importantly, you need to extend ViewsBulkOperationsActionBase instead of ConfigurableActionBase.

class YourAction extends ViewsBulkOperationsActionBase

...
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    ...
    $selectedItems = array_map(function ($listItem) {
      return reset($listItem);
    }, $this-&gt;context['list']);
    ...
  }
...


This will give you an array whose values are the entity ids of the selected items in your view. The keys of the array are the bulkFormKey for each selected entity.

See ViewsBulkOperationsFormTrait::calculateEntityBulkFormKey() and ViewsBulkOperationsFormTrait::getListItem() for more information about bulkFormKeys.

Hope this helps, good luck!

P.S.: And for anyone else landing here, the related VBO's documentation page is over at https://www.drupal.org/docs/8/modules/views-bulk-operations-vbo/configuring-an-action