In the field of industrial engineering, the joint optimization of maintenance and spares inventory has attracted more and more attention because it can better balance system availability and cost. However existing studies are usually restricted to a single failure mode and a simple maintenance strategy of the single component systems. To bridge these gaps, this paper investigates the joint optimization of condition-based maintenance and spares inventory for a general series–parallel system with two failure modes. Hard failures are self-announcing, and soft failures are generally caused by the degradation of components and only be discovered through inspection. At the time of each periodic inspection, the corresponding corrective maintenance, preventive maintenance and spare parts ordering policy are determined. Upon a hard failure occurs, an opportunistic inspection will be performed, and it will be determined whether to perform maintenance actions based on the degradation level of the components and spares inventory level. Furthermore, the state transition probability and the expected sojourn time can be derived by the formulated semi-Markov decision process. To minimize the expected average cost per unit time, the optimal preventive maintenance and the spares inventory control policies are jointly determined by applying a simulation method. Finally, a numerical experiment is presented to demonstrate the effectiveness and superiority of the proposed joint optimization model.