Here is an answer I came up with. I am basically using an explicit deformation retraction of the cone to its apex point. To do this I'll first deformation retract $Y\times I$ to $Y\times\{1\}$ and then consider the image of this under the natural projection. I believe this is precisely what you suggest to do without making use of the deformation retraction explicitly.
By the way, for future reference, this is exercise 5.6 on page 91 of Armstrong's Basic Topology.
Disclaimer 1: I know that deformation retractions are introduced later in the book, and I tried to avoid using them at first, but maybe Armstrong wants the reader to find out about them. I did come up with two other ideas that do not use deformation retractions, but I could not make too much use of them. If either of them turn out to be useful I'll add it later.
Disclaimer 2: I am not very well-versed in category theory, so pardon my diagram if it contains redundant information.
First let me introduce some notation. Let $\alpha:=Y\times\{1\}\in CY$ be the apex point of the cone $CY$, and $c_\alpha: X\to CY, x\mapsto\alpha$ be the constant map at $\alpha$. Let $\pi: Y\times I\to CY$ be the natural projection, i.e., $\pi(y,s):=\begin{cases} \alpha&,\mbox{if } s=1\\ \{(y,s)\}&,\mbox{if } s<1\end{cases}$.
Consider the following diagram:
$$\begin{array} &Y& \cong &Y\times\{0\}& \hookrightarrow &Y\times I& \cong &(Y\times I)\times \{0\}& \hookrightarrow &(Y\times I)\times I& \stackrel{F_0}{\longrightarrow} &Y\times I& \\
&&& &\downarrow{\pi} && \downarrow{(\pi,id)} && \downarrow{(\pi,id)} &\curvearrowright& \downarrow{\pi}\\
& && &CY& \cong &CY\times\{0\}& \hookrightarrow &CY\times I& \stackrel{F}{\longrightarrow} &CY,&
\end{array}$$
where
$$F_0:(Y\times I)\times I\to Y\times I,((y,s),t)\mapsto (y,(1-t)s+t)$$
and
$$F:CY\times I\to CY, (\pi(y,s),t)\mapsto \pi(F_0((y,s),t))=\pi(y,(1-t)s+t).$$
Observe that $F$ is defined so that $F\circ(\pi,id)=\pi\circ F_0$. Thus the continuity of $F_0$ will guarantee the continuity of $F$.
$F_0$ is a deformation retraction of $Y\times I$ onto $Y\times \{1\}$. Indeed, $F_0$ is clearly continuous and
\begin{align}
&F_0((y,s),0)=(y,s)=id_{Y\times I}(y,s)\\
&F_0((y,s),1)=(y,1)\in Y\times\{1\}\\
&F_0((y,1),t)=(y,1)=id_{Y\times I}(y,1)\\
\end{align}
Next let us see that $F$ is well-defined. If $y,y'\in Y$, we have
$$F(\pi(y,1),t)=\pi(y,1)=\alpha=\pi(y',1)=F(\pi(y',1),t).$$
Then $F$ deformation retracts $CY=\pi(Y\times I)$ onto $\{\alpha\}=\pi(Y\times\{1\})$ by construction.
Let $f:X\to CY$ be a continuous function. Set
$$f(x):=\begin{cases}\alpha=\pi(y',1)&,\mbox{if } x\in f^{-1}(\alpha)\\
\{y_x,s_x\}=\pi(y_x,s_x)&, \mbox{if } x\not\in f^{-1}(\alpha)\end{cases}.$$
Here $y'\in Y$ is arbitrary but $y_x$ and $s_x$ (possibly) depend on $x\in X-f^{-1}(\alpha)$. Since both $F$ and $f$ are continuous, so is
$$G:X\times I\to CY, (x,t)\mapsto F(f(x),t)=F\circ(f,id)(x,t).$$
Moreover we have
\begin{align}
&G(x,0)=F(f(x),0)=\begin{cases} \alpha&,\mbox{if } x\in f^{-1}(\alpha)\\ \pi(y_x,s_x)&,\mbox{if } x\not\in f^{-1}(\alpha)\end{cases}=f(x)\\
&G(x,1)=F(f(x),1)=\alpha=c_\alpha(x)\\
&\forall x\in f^{-1}(\alpha): G(x,t)=F(\alpha,t)=\alpha=f(x)=c_\alpha(x)
\end{align}
Hence $f\underset{G}{\simeq} c_\alpha$ rel $f^{-1}(\alpha)$. Since homotopy relative to a subset of the domain is an equivalence relation, any two continuous function $X\to CY$ are homotopic to each other.