diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 94404eee7..0097ebd52 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -30,3 +30,18 @@ jobs: -F RELEASE_NOTES.md \ "v${OPERATOR_VERSION}" \ 'dist/tempo-operator.yaml#Installation manifest for Kubernetes' \ + + + operator-hub-prod-release: + needs: release + uses: ./.github/workflows/reusable-operator-hub-release.yaml + with: + org: redhat-openshift-ecosystem + repo: community-operators-prod + + operator-hub-community-release: + needs: release + uses: ./.github/workflows/reusable-operator-hub-release.yaml + with: + org: k8s-operatorhub + repo: community-operators \ No newline at end of file diff --git a/.github/workflows/reusable-operator-hub-release.yaml b/.github/workflows/reusable-operator-hub-release.yaml new file mode 100644 index 000000000..acb357a54 --- /dev/null +++ b/.github/workflows/reusable-operator-hub-release.yaml @@ -0,0 +1,92 @@ +name: Reusable - Create operator hub pull request + +on: + workflow_call: + inputs: + org: + type: string + required: true + repo: + type: string + required: true + +jobs: + create-operator-pull-request: + runs-on: ubuntu-latest + steps: + - name: Generate token + id: generate_token + uses: tibdex/github-app-token@v1 + with: + app_id: ${{ secrets.APP_ID }} + private_key: ${{ secrets.PRIVATE_KEY }} + - name: Set version as env variable + env: + TAG: ${{ github.ref_name }} + run: | + echo $TAG + TAG=${TAG:1} # remove v (prefix) + echo version=${TAG} >> $GITHUB_ENV # update GitHub ENV vars + + - name: Sync fork + env: + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + # synchronizing the fork is fast, and avoids the need to fetch the full upstream repo + # (fetching the upstream repo with "--depth 1" would lead to "shallow update not allowed" + # error when pushing back to the origin repo) + gh repo sync grafana/${{ inputs.repo }} \ + --source ${{ inputs.org }}/${{ inputs.repo }} \ + --force + + - name: Checkout operatorhub repo + uses: actions/checkout@v3 + with: + repository: grafana/${{ inputs.repo }} + token: ${{ steps.generate_token.outputs.token }} + + - name: Checkout tempo-operator to tmp/ directory + uses: actions/checkout@v3 + with: + repository: grafana/tempo-operator + token: ${{ steps.generate_token.outputs.token }} + path: tmp/ + + - name: Update version + env: + VERSION: ${{ env.version }} + run: | + mkdir operators/tempo-operator/${VERSION} + cp -R ./tmp/bundle/* operators/tempo-operator/${VERSION} + rm -rf ./tmp + + - name: Use CLA approved github bot + run: | + git config user.name tempobot + git config user.email 107717825+grafana@users.noreply.github.com + + - name: Create pull request against ${{ inputs.org }}/${{ inputs.repo }} + env: + VERSION: ${{ env.version }} + GH_TOKEN: ${{ steps.generate_token.outputs.token }} + run: | + message="Update the tempo to $VERSION" + body="Release tempo-operator \`$VERSION\`. + + cc @pavolloffay @frzifus @andreasgerstmayr @rubenvp8510 @iblancasa + " + branch="update-tempo-operator-to-${VERSION}" + + # gh pr create doesn't have a way to explicitly specify different head and base + # repositories currently, but it will implicitly pick up the head from a different + # repository if you set up a tracking branch + + git checkout -b $branch + git add -A + git commit -s -m "$message" + git push -f --set-upstream origin $branch + gh pr create --title "$message" \ + --body "$body" \ + --repo ${{ inputs.org }}/${{ inputs.repo }} \ + --base main +