You follow the steps in What to do before you sell, give away, or trade in your Mac. If you cannot get it to run, then you don't need to worry about the data. Just have the old machine recycled by Apple, follow Apple Recycling Programs
To migrate, follow the directions below!!!!!!!!!!!!!!!!!
If the old Mac has more data stored on it than 256GB, then buy one that has adequate storage (same as or more than the old computer) or your migration will be difficult and messy.
When you buy a new Mac the easiest, quickest and most reliable method to migrate from the old Mac to the new Mac is to simply connect the old Mac's Time Machine External Hard Disk to the new Mac using a USB cable before you turn on the new Mac. You will likely need a USB A to USB C adapter, you can find them on Amazon for $10 or less. When you start the new Mac for the first time it will startup Setup Assistant (SA), SA will get to a point where it asks if you are migrating from another computer, select Yes and follow the on-screen prompts and it's done! It is THAT simple.
If you have already done SA on the new computer then simply connect the Time Machine External Hard Disk using a USB cable and launch Migration Assistant (MA) which is located in Applications - Utilities - MA. Then follow the on-screen prompts.
The ONLY difference between MA and SA is MA will create a new user account that you need to log into.
Both SA and MA migrate applications (not 32 bit apps), data files & settings. They do not migrate Mac OS itself. Some professional apps such as Adobe and Microsoft apps may require re-installing their apps as they will not allow them to be migrated. As long as you kept the security keys for installing their apps, it is not an issue.
Finally, never EVER use Wi-Fi when doing Setup Assistant or Migration Assistant. Why, it simply fails in most cases. Please read and follow the directions in Setup Assistant and Migration Assistant. If you do not have a Time Machine backup of the older Mac then create one! If you are not aware of Time Machine, please read Back up your Mac with Time Machine and finally if you need an External Hard Disk to use as a Time Machine External Hard Disk then many experience users on these forums prefer the OWC Mercury Elite Pro due to it's reasonable price, high level of quality and ease of use.