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
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
- name: validate env
run: |
echo "$VERSION"
echo "$COMMUNITY_BRANCH_NAME"
echo "$TARGET_GH_ORG"
echo "$TARGET_GH_REPO"
# - name: create github token
# uses: actions/[email protected]
# id: app-token
# with:
## app-id: ${{vars.GH_APP_ID}}
## private-key: ${{secrets.GH_APP_PRIVATE_KEY}}
# repositories: "datadog-operator,community-operators,community-operators-prod,redhat-marketplace-operators,certified-operators"
- name: checkout fork
uses: actions/checkout@v4
with:
repository: DataDog/${{ inputs.repo }}
token: ${{ secrets.GH_ROBOT_TOKEN }}
- name: sync fork
env:
GITHUB_TOKEN: ${{secrets.GH_ROBOT_TOKEN}}
run: |
git checkout -b $COMMUNITY_BRANCH_NAME
git push -f --set-upstream origin $COMMUNITY_BRANCH_NAME
gh repo sync DataDog/${{ inputs.repo }} --branch $COMMUNITY_BRANCH_NAME \
--source ${{ inputs.org }}/${{ inputs.repo }} \
--force
- name: checkout datadog-operator to tmp/ dir
uses: actions/checkout@v4
with:
repository: Datadog/datadog-operator
token: ${{secrets.GH_ROBOT_TOKEN}}
path: tmp/
run: |
if [[ "${{ !inputs.community_repo }}" ]]; then
make bundle-redhat
fi
- name: update bundle
if: ${{ inputs.community_repo }}
run: |
mkdir operators/datadog-operator/$VERSION
cp -R ./tmp/bundle/* operators/datadog-operator/$VERSION
rm -rf ./tmp
- name: update redhat bundle
if: ${{ !inputs.community_repo }}
run: |
mkdir operators/datadog-operator/$VERSION
if [[ "${{ inputs.repo }}" == "redhat-marketplace-operators" ]]; then
cp -R ./tmp/bundle-redhat-mp/* operators/datadog-operator/$VERSION
elif [[ "${{ inputs.repo }}" == "certified-operators" ]]; then
cp -R ./tmp/bundle-redhat-mp/* operators/datadog-operator/$VERSION
fi
cp -R ./tmp/bundle-redhat/* operators/datadog-operator/$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 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