This is kind of a hard one. On one hand, the RAM in the 2018 mini is upgradable (though it requires quite a bit of disassembly to get to the RAM sockets). The CPU is not. On the other hand, according to Geekbench going from the i5 to the i7 only gets you about a 10% bump in single core performance and a 20% bump in multicore performance, which is not huge.
This really comes down to how you’re planning to use the machine. I recently had to make this decision myself. Mine is intended as a home server, but I wanted the potential to use it as a desktop in the future. I ended up going with the i5 and 8GB of RAM, with the idea that if I did use it as a desktop and found the RAM inadequate, I could always upgrade it.
If you were set on getting one or the other, I’d probably lean towards the RAM upgrade. You might also want to consider putting this money towards a larger SSD. That may be a better quality of life improvement than either the faster processor or the additional RAM.