Group actions and anomalies in gauge theories