It is not necessarily true unless the domain is connected.
If the domain $X$ is connected and $f$ is continuous, then $f(X)$ is also connected. The only connected subsets of the integers are sets containing at most one point. Hence $f(X)$ (which is presumably non-empty) has exactly one point and $f$ is constant on $X$.
Another approach is to suppose that $y_1=f(x_1), y_2=f(x_2)$. Suppose $y_1\leq y_2$ without loss of generality. Then by the intermediate value theorem, $f$ must take all the values in $[y_1,y_2]$. However, since the range is the integers, this can only be true if $f$ only takes one value.
Here's a third approach: Since $f$ is continuous, for each $x_0$ we can find a $\delta>0$ such that if $|x-x_0|<\delta$, then $|f(x)-f(x_0)| < \frac{1}{2}$. Since $f$ is integer valued, this means that $f(x) = f(x_0)$ for all $|x-x_0|<\delta$.
Now let $t_+ = \sup \{x | f(x) = f(0)\}$. If $t_+<\infty$, then by continuity, we must have $f(t_+) = f(0)$, and by the previous paragraph, there is a $\delta>0$ such that $f(x) = f(t_+)$ for all $x$ satisfying $|x-t_+| < \delta$, which contradicts the definition of $t_+$. Hence $t_+ = \infty$. Applying the same approach to $t_- = \inf \{x | f(x) = f(0)\}$ shows that $t_- = -\infty$, hence $f(x) =f(0)$ for all $x$.