First principle of stationary action
Consider a real Klein-Gordon scalar field $\phi$ living in a $D$ dimensional flat spacetime. The field is considered off shell (the on shell condition is defined below). Suppose for simplicity that its action on an arbitrary region of spacetime $\Omega$ is \begin{equation}\tag{1} S = \int_{\Omega} \frac{1}{2} \big((\partial_a \, \phi )(\partial^a \, \phi) - m^2 \phi^2 \big) d^D x. \end{equation} The on shell field is defined as the one which render the action stationary under an arbitrary compactly supported variation of the field. The variation $\delta \phi$ is an arbitrary smooth function with compact support (it is not necessarily analytic). It is vanishing on the boundary $\partial \, \Omega$, and all its derivatives are also vanishing there ; $\delta \phi = 0$ and $\partial_a \, \delta \phi = 0$ on $\partial \, \Omega$. An arbitrary variation of the field induces a variation of its action : \begin{align} \delta S &= \int_{\Omega} \big( (\partial_a \, \phi )(\partial^a \, \delta \phi) - m^2 \phi \, \delta \phi \big) d^D x \\[18pt] &= \int_{\Omega} \partial^a \big( (\partial_a \phi) \, \delta \phi \big) \, d^D x - \int_{\Omega} \big( \partial^a \, \partial_a \phi + m^2 \phi \big) \, \delta \phi \; d^D x. \tag{2} \end{align} The first integral gives a surface term, by virtue of the Gauss theorem. It's vanishing if $\delta \phi = 0$ on $\partial \, \Omega$. Since $\delta \phi$ is arbitrary inside the bulk of $\Omega$, we get the Klein-Gordon equation, which defines the on shell condition : \begin{equation} \partial^a \, \partial_a \phi + m^2 \phi = 0. \tag{3} \end{equation} This is all fine with the usual variational principle. However, to solve the on shell differential equation (i.e the equation of motion), we need some proper boundary conditions that should be imposed on the scalar field. Obviously, they should be compatible with the equation of motion. Without them, the equation of motion cannot be solved. What is the "law" that defines the boundary conditions to be imposed on the field ?
Second principle of stationary action (hypothetical method to find the boundary conditions on the field)
Now consider an on shell field $\phi$ with some unknown boundary conditions on $\partial \, \Omega$. An arbitrary small variation of the boundary conditions induces a variation of the field ; $\phi' = \phi + \delta \phi$, which is still on shell. In this case, the variation $\delta \phi$ and its derivatives do not necessarily vanish on the boundary ! ($\delta \phi$ is not anymore of compact support). The change of boundary conditions also produces a change in the action : \begin{equation}\tag{4} \delta S = \int_{\Omega} \partial^a \big( (\partial_a \phi) \; \delta \phi \big) \, d^D x - \int_{\Omega} \big( \partial^a \, \partial_a \phi + m^2 \phi \big) \, \delta \phi \; d^D x. \end{equation} Since the field is on shell, the equation of motion is satisfied in the bulk and the second integral vanishes. We now get a surface integral : \begin{equation}\tag{5} \delta S = \int_{\partial \, \Omega} (\partial_a \phi) \, \delta \phi \; d\sigma^a, \end{equation} where $d\sigma^a$ are the components of the outward boundary normal. Lets suppose that the action is still stationary under the variation of the boundary conditions of an on shell field. The condition $\delta S = 0$ then imposes \begin{equation}\tag{6} (d\sigma^a \; \partial_a \phi) \, \delta \phi = 0, \end{equation} everywhere on the boundary $\partial \, \Omega$ (I'm not sure this is right, since the surface integral is a flux. Maybe it is just the integral which vanishes). This suggest two choices : \begin{align}\tag{7} \delta \phi &= 0 \; \text{(Dirichlet conditions),} &&\text{or} &d\sigma^a \; \partial_a \phi &= 0 \; \text{(Neumann conditions).} \end{align}
So to summarize: I use the stationary action principle to get the field equations, and then use the principle again but now together with the field equations in order to see what are the possible boundary conditions.
Now, the question is this :
Do the previous procedure actually make sense ?
How can we make the boundary conditions more precise, in details ?
And more specifically, how should we translate the Dirichlet conditions above ; $\delta \phi = 0$ on the boundary $\partial \, \Omega$ ? I'm unable to make sense of this part.
Take note that the arbitrary region of spacetime $\Omega$ and its boundary $\partial \, \Omega$ are fixed here, and there is no variation on coordinates (which are fixed). The boundary conditions that I'm talking about refer to the field configuration on $\partial \, \Omega$, which is a closed hypersurface in spacetime, enclosing the arbitrary region $\Omega$.
What are your opinion on this hypothetical (unconventional ?) application of the stationary action principle ?
EDIT: Please, use the same variables (i.e. a scalar field) in your answer, to talk about "boundary conditions" on $\partial \Omega$ of a field in spacetime, instead of "initial conditions". To me, there's a huge distinction between "field boundaries" and "initial conditions".
Very important: Take note that I may be using the "Nature" Hamilton-Jacobi action and not the "observer" Euler-Lagrange action (I'm not sure yet), as defined in this paper :
https://arxiv.org/abs/1203.2736
As a reference to this question, see section 2 (page 4) of the following paper from Padmanabhan: