Rotate multiple cube as one

Hi I am new at Unity and I am trying to create a rubiks cube application.
I recently hit a road block which is I can’t seem to rotate the cube pieces.

As you can see I want to rotate the cubes as one but they don’t seem to respond at all
This is the code I am using:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Cube : MonoBehaviour {

public GameObject rubix;
private GameObject[] cube;
private GameObject[] face;
private GameObject rightPivot;
private int i;

void Start()
{
    cube = GameObject.FindGameObjectsWithTag("cube");
    face = new GameObject[9];
    RotateRight();
}

void RotateRight()
{
    i = 0;
    rightPivot = new GameObject("rightPivot");
    rightPivot.transform.position = new Vector3(2, 1, 1);
    rightPivot.transform.parent = rubix.transform;
    foreach (GameObject cube in cube)
    {
        if (cube.transform.position.x == 2)
        {
            cube.transform.parent = rightPivot.transform;
            cube.name = "Right Face Cube";
            face *= cube;*

i++;
}
}
}
void Update()
{
rightPivot.transform.RotateAround(rightPivot.transform.position, Vector3.right, Time.deltaTime);
}
}

You can make them all children of a single gameobject, rotate the parent and then remove that parent component. You can do this by setting each cube’s transform.parent to a new gameobject you create and set each cube’s transform.parent to null or its previous parent.