Skip to content
#name: publish_community_operators
#
#on:
# workflow_call:
# inputs:
# community_repo:
# type: boolean
# required: true
# org:
# type: string
# required: true
# repo:
# type: string
# required: true
# dir:
# type: string
# required: false
# secrets:
# GH_ROBOT_TOKEN:
# required: true
#
#jobs:
# create-pull-request:
# runs-on: ubuntu-latest
# env:
# GH_REF_NAME: vX.Y.Z # placeholder for testing
# BRANCH_NAME_BASE: ${{ github.actor }}/datadog-operator
# ACTIONS_RUNNER_DEBUG: true
# steps:
# - name: setup env
# run: |
# echo "VERSION=${GH_REF_NAME:1:5}" >> $GITHUB_ENV
# echo "COMMUNITY_BRANCH_NAME=$BRANCH_NAME_BASE-$GH_REF_NAME" >> $GITHUB_ENV
# echo "TARGET_GH_ORG=${{ inputs.org }}" >> $GITHUB_ENV
# echo "TARGET_GH_REPO=${{ inputs.repo }}" >> $GITHUB_ENV
# echo "BUNDLE_PATH=bundle" >> $GITHUB_ENV
#
# if [[ ${{ inputs.community_repo }} == false ]]; then
# mkdir ~/.redhat
# echo -n "${{ secrets.REDHAT_TOKEN }}" | base64 --decode > ~/.redhat/auths.json
# ls ~/.redhat/auths.json
# du -sh ~/.redhat/auths.json
#
# if [[ "${{ inputs.repo }}" == "redhat-marketplace-operators" ]]; then
# echo "BUNDLE_PATH=bundle-redhat-mp" >> $GITHUB_ENV
# elif [[ "${{ inputs.repo }}" == "certified-operators" ]]; then
# echo "BUNDLE_PATH=bundle-redhat" >> $GITHUB_ENV
# fi
# fi
#
# - name: validate env
# run: |
# echo "$VERSION"
# echo "$COMMUNITY_BRANCH_NAME"
# echo "$TARGET_GH_ORG"
# echo "$TARGET_GH_REPO"
# echo "$BUNDLE_PATH"
#
# - name: sync fork
# env:
# GH_TOKEN: ${{secrets.GH_ROBOT_TOKEN}}
# run: |
# echo $PWD
# gh repo sync DataDog/${{ inputs.repo }} --branch $COMMUNITY_BRANCH_NAME \
# --source ${{ inputs.org }}/${{ inputs.repo }} \
# --force
#
# - name: checkout fork
# uses: actions/checkout@v4
# with:
# repository: DataDog/${{ inputs.repo }}
# token: ${{ secrets.GH_ROBOT_TOKEN }}
#
# - name: checkout datadog-operator to tmp/ dir
# uses: actions/checkout@v4
# with:
# repository: Datadog/datadog-operator
# token: ${{secrets.GH_ROBOT_TOKEN}}
# path: tmp/
#
# - name: update bundle
# env:
# REDHAT_TOKEN: ${{ secrets.REDHAT_TOKEN }}
# shell: bash
# run: |
# if [[ ${{ inputs.community_repo }} == false ]]; then
# skopeo login -v --authfile ~/.redhat/auths.json registry.connect.redhat.com
# make -C ./tmp bundle-redhat
# fi
# mkdir operators/$OPERATOR_DIR/$VERSION
# cp -R ./tmp/$BUNDLE_PATH/* operators/${{ inputs.dir }}/$VERSION
# rm -rf ./tmp
#
# - name: Configure git user
# run: |
# git config --global user.name ${{ github.actor }}
# git config --global user.email ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
#
# - name: create PR
# env:
# GH_TOKEN: ${{secrets.GH_ROBOT_TOKEN}}
# run: |
# message="operator datadog-operator ($VERSION)"
# body="operator datadog-operator ($VERSION)"
# git checkout -b $COMMUNITY_BRANCH_NAME
# git add -A
# git commit -s -m "$message"
# git push -f --set-upstream origin $COMMUNITY_BRANCH_NAME
# gh pr create --title "$message" \
# --body "$body" \
# --repo DataDog/${{ inputs.repo }} \
# --base main \
# --draft