As @mƎALLEm said, you use header files (.h) to provide the declarations of the things you want to share.
This is standard C stuff - nothing specific or special to CubeIDE:
https://c-faq.com/decl/decldef.html
eg, file.h provides declarations:
extern int variable1;
extern char variable1;
extern float variable1;
void function_1( void );
file.c provides definitions (or "implementations"):
int variable1;
char variable2;
float variable3;
void function_1( void )
{
// your code here
}
Now, for example, your main.c can access things from file.c by #including file.h:
#include "file.h"
int main( void )
{
int local_variable1 = 2 * variable1; // use the variables from file.c
char local_variable2 = 3 + variable2;
float local_variable3 = 2.3 / variable1;
function_1(); // call the function from file.c
:
:
Update: https://community.st.com/t5/stm32cubeide-mcus/adding-new-c-source-files-to-my-project-and-navigating-through/m-p/658310/highlight/true#M25925
Here is a pictorial summary:

PS:
More on declarations vs definitions (including the difference between preprocessor definitions, and function/variable definitions):
https://community.st.com/t5/stm32-mcus-embedded-software/use-of-c-or-h-files/m-p/793732/highlight/true#M62344
#DeclDef
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.