diff --git a/.github/workflows/release-openshift.yaml b/.github/workflows/release-openshift.yaml new file mode 100644 index 0000000000..9067f094b0 --- /dev/null +++ b/.github/workflows/release-openshift.yaml @@ -0,0 +1,106 @@ +name: Release Openshift +on: + workflow_dispatch: + inputs: + version: + description: "Release version:" + required: true +jobs: + release-openshift: + name: "Create Pull request for openshift release" + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ github.token }} + REPO_PATH: "operators/mongodb-atlas-kubernetes" + strategy: + matrix: + repository: ["mongodb-forks/community-operators", "mongodb-forks/community-operators-prod", "mongodb-forks/certified-operators"] + include: + - repository: "mongodb-forks/certified-operators" + certified: true + steps: + - name: Clone/Checkout Atlas Operator + uses: actions/checkout@v3.1.0 + with: + ref: main + path: "mongodb-atlas-kubernetes" + fetch-depth: 0 + - name: Clone/Checkout releases repositories + uses: actions/checkout@v3.1.0 + with: + repository: ${{ matrix.repository }} + ref: main + path: ${{ matrix.repository }} + token: ${{ github.token }} + - name: Prepare version + env: + VERSION: ${{ github.event.inputs.version }} + REPOSITORY: ${{ matrix.repository }} + run: | + cd $REPOSITORY + mkdir -p "${REPO_PATH}/${VERSION}" + + cd ../../mongodb-atlas-kubernetes + cp -r bundle.Dockerfile bundle/manifests bundle/metadata bundle/tests "../${REPOSITORY}/${REPO_PATH}/${VERSION}" + - name: Configure non-certified release + if: ${{ ! matrix.certified }} + env: + VERSION: ${{ github.event.inputs.version }} + REPOSITORY: ${{ matrix.repository }} + run: | + echo "Configure non-certified release" + cd "$REPOSITORY/$REPO_PATH" + sed -i.bak 's/COPY bundle\/manifests/COPY manifests/' "${VERSION}/bundle.Dockerfile" + sed -i.bak 's/COPY bundle\/metadata/COPY metadata/' "${VERSION}/bundle.Dockerfile" + sed -i.bak 's/COPY bundle\/tests\/scorecard/COPY tests\/scorecard/' "${VERSION}/bundle.Dockerfile" + rm "${VERSION}/bundle.Dockerfile.bak" + - name: Certify Openshift images + uses: ./.github/actions/certify-openshift-images + with: + repository: quay.io/mongodb/mongodb-atlas-kubernetes-operator + version: ${{ github.event.inputs.version }} + quay_password: ${{ secrets.QUAY_PASSWORD }} + rhcc_token: ${{ secrets.RH_CERTIFICATION_PYXIS_API_TOKEN }} + rhcc_project: ${{ secrets.RH_CERTIFICATION_OSPID }} + - name: Configure certified release + if: ${{ matrix.certified }} + env: + VERSION: ${{ github.event.inputs.version }} + REPOSITORY: ${{ matrix.repository }} + IMAGE: quay.io/mongodb/mongodb-atlas-kubernetes-operator + run: | + # Reference to image + REPO_DIGEST=$(docker inspect --format='{{ index .RepoDigests 0}}' "${IMAGE}":"${VERSION}") + containerImage="quay.io/${REPO_DIGEST}" + yq e -i '.metadata.annotations.containerImage = env(containerImage)' "${VERSION}"/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml + yq e -i '.spec.install.spec.deployments[0].spec.template.spec.containers[0].image = env(containerImage)' "${VERSION}"/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml + + # Add skip range + value='">=0.8.0"' yq e -i '.spec.skipRange = env(value)' "${VERSION}"/manifests/mongodb-atlas-kubernetes.clusterserviceversion.yaml + - name: Push Changes & Open PR + env: + VERSION: ${{ github.event.inputs.version }} + REPOSITORY: ${{ matrix.repository }} + ASSIGNEES: priyolahiri,fabritsius,igor-karpukhin,sugar-pack,helderjs + run: | + cd "$REPOSITORY/$REPO_PATH" + + # Sync fork + gh auth setup-git + gh repo sync -b main + + # configure git user + git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + # commit, push + git checkout -b "mongodb-atlas-operator-community-${VERSION}" + git add "${VERSION}" + git status + git commit -m "MongoDB Atlas Operator ${VERSION}" --signoff + git push origin "mongodb-atlas-operator-community-${VERSION}" + + # open PR + gh pr create \ + --title "operator mongodb-atlas-kubernetes (${VERSION})" \ + --assignee "${ASSIGNEES}" \ No newline at end of file