In this paper, we present a data-driven secondary controller for regulating to some desired values several variables of interest in a power system, namely, electrical frequency, voltage magnitudes at critical buses, and active power flows through critical lines. The power generation system is based on distributed energy resources (DERs) interfaced with either grid-forming (GFM) or grid-following (GFL) inverters. The secondary controller is based on online feedback optimization leveraging the learned sensitivities of the changes in the system frequency, voltage magnitudes at critical buses, and active power flows through critical lines to the changes in inverter active and reactive power setpoints. To learn the sensitivities accurately from data, the feedback optimization has a built-in mechanism for keeping the secondary control inputs persistently exciting without degrading its performance. The feedback optimization also utilizes the learned power-voltage characteristics of photovoltaic (PV) arrays to compute DC-link voltage setpoints so as to allow the PV arrays to track the power setpoints. To learn the power-voltage characteristics, we separately execute a data-driven approach that fits a concave polynomial to the collected power-voltage measurements by solving a sum-of-squares (SoS) optimization. We showcase the secondary controller using the modified IEEE-14 bus test system, in which conventional energy sources are replaced with inverter-interfaced DERs.