An action principle for the Einstein–Weyl equations