סימן פז סעיף ט
מֻתָּר לוֹמַר לְאֵינוֹ יְהוּדִי לַחֲלוֹב הַבְּהֵמוֹת בַּשַׁבָּת, מִשּׁוּם צַעַר בַּעֲלֵי חַיִּים, כִּי הֶחָלָב מְצַעֲרָהּ. וְהֶחָלָב אָסוּר בּוֹ בַּיּוֹם אֲפִלּוּ בְּטִלְטוּל, אֶלָּא הָאֵינוֹ יְהוּדִי יַעֲמִידֶנּוּ בְּמָקוֹם הַמִּשְׁתַּמֵּר. וְכֵן מֻתָּר לוֹמַר לְאֵינוֹ יְהוּדִי, לְהַבְרוֹת הָאַוָּזוֹת פַּעַם אַחַת בַּיּוֹם, מִשּׁוּם צַעַר בַּעֲלֵי חַיִּים (סִימָן ש"ה).
You may tell a non-Jew to milk the cows on Shabbos,22Milking is considered a de’oraisa prohibition by many poskim (see chapter 80, note 62). Therefore, the Mishnah Berurah (305: 73) suggests that it is preferable to have the non-Jew do the milking into food which constitutes only a derabanan prohibition.
If a non-Jew is unavailable, then, according to Chazon Ish (56: 4) and Igros Moshe (1: 95) you may milk onto the ground or into whatever else will cause the milk to go to waste.
Concerning milking machines, see Chazon Ish 38: 34. to avoid causing pain to the animals, because the milk causes them pain. [However,] that milk is forbidden even to be handled on that day. Instead, the non-Jew should place it in a safe place. Similarly, you may tell a non-Jew to force-feed the geese once a day23Geese which have been force fed over an extended period can usually no longer eat on their own. If a non-Jew is unavailable, you may feed the geese yourself, though having a minor do so would be preferable. [Mishnah Berurah 305: 71] to avoid causing pain to living creatures.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)