The use of graphene in electronic devices requires a band gap, which can be achieved by creating nanostructures such as graphene nanoribbons. A wide variety of atomically precise graphene nanoribbons can be prepared through on-surface synthesis, bringing the concept of graphene nanoribbon electronics closer to reality. For future applications it is beneficial to integrate contacts and more functionality directly into single ribbons by using heterostructures. Here, we use the on-surface synthesis approach to fabricate a metal-semiconductor junction and a tunnel barrier in a single graphene nanoribbon consisting of 5- and 7-atom wide segments. We characterize the atomic scale geometry and electronic structure by combined atomic force microscopy, scanning tunneling microscopy, and conductance measurements complemented by density functional theory and transport calculations. These junctions are relevant for developing contacts in all-graphene nanoribbon devices and creating diodes and transistors, and act as a first step toward complete electronic devices built into a single graphene nanoribbon.