forked from grafana/loki
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(operator): adds reusable workflow for opening PRs to hub repos (g…
…rafana#12149) Co-authored-by: Trevor Whitney <[email protected]>
- Loading branch information
1 parent
04cf7e5
commit 1e7ee4d
Showing
4 changed files
with
133 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: "Publish release on operator hub" | ||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
operator-hub-prod-release: | ||
if: startsWith(github.event.release.tag_name, 'operator/') | ||
uses: ./.github/workflows/operator-reusable-hub-release.yaml | ||
with: | ||
org: redhat-openshift-ecosystem | ||
repo: community-operators-prod | ||
secrets: | ||
GRAFANABOT_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | ||
|
||
operator-hub-community-release: | ||
if: startsWith(github.event.release.tag_name, 'operator/') | ||
uses: ./.github/workflows/operator-reusable-hub-release.yaml | ||
with: | ||
org: k8s-operatorhub | ||
repo: community-operators | ||
secrets: | ||
GRAFANABOT_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
name: Reusable - Create operator hub pull request | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
org: | ||
type: string | ||
required: true | ||
repo: | ||
type: string | ||
required: true | ||
secrets: | ||
GRAFANABOT_GITHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
create-operator-pull-request: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set redhat-openshift-ecosystem specific variables | ||
if: ${{ inputs.org == 'redhat-openshift-ecosystem' }} | ||
env: | ||
ocpDir: '/path/to/openshift/directory' | ||
ocpSupportedVersions: 'v4.12' | ||
run: | | ||
echo "ocpDir=${ocpDir}" >> $GITHUB_ENV | ||
echo "ocpSupportedVersions=${ocpSupportedVersions}" >> $GITHUB_ENV | ||
- name: Set version as env variable | ||
env: | ||
TAG: ${{ github.ref_name }} | ||
run: | | ||
echo $TAG | ||
TAG=${TAG:10} # remove "operator/v" (prefix) | ||
echo version=${TAG} >> $GITHUB_ENV # update GitHub ENV vars | ||
- name: Sync fork | ||
env: | ||
GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_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 grafanabot/${{ inputs.repo }} \ | ||
--source ${{ inputs.org }}/${{ inputs.repo }} \ | ||
--force | ||
- name: Checkout operatorhub repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: grafanabot/${{ inputs.repo }} | ||
token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} | ||
|
||
- name: Checkout loki to tmp/ directory | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: grafana/loki | ||
token: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} | ||
path: tmp/ | ||
|
||
- name: Update version | ||
env: | ||
VERSION: ${{ env.version }} | ||
OCP_DIR: ${{ env.ocpDir || ''}} | ||
run: | | ||
mkdir operators/loki-operator/${VERSION} | ||
cp -R ./tmp/operator/bundle/community${OCP_DIR}/* oOCP_DIR}/* opperators/loki-operator/${VERSION} | ||
rm -f "operators/loki-operator/${VERSION}/bundle.Dockerfile" | ||
rm -rf ./tmp | ||
- name: Add OpenShift Supported versions to redhat catalog | ||
if: ${{ inputs.org == 'redhat-openshift-ecosystem' }} | ||
env: | ||
VERSION: ${{ env.version }} | ||
OCP_SUPPORTED_VERSIONS: ${{ env.ocpSupportedVersions || ''}} | ||
uses: fjogeleit/yaml-update-action@main | ||
with: | ||
valueFile: "./operators/loki-operator/${VERSION}/metadata/annotations.yaml" | ||
propertyPath: "annotations['com.redhat.openshift.versions']" | ||
value: ${OCP_SUPPORTED_VERSIONS} | ||
|
||
- name: Use CLA approved github bot | ||
run: | | ||
git config user.name grafanabot | ||
git config user.email [email protected] | ||
- name: Create pull request against ${{ inputs.org }}/${{ inputs.repo }} | ||
env: | ||
VERSION: ${{ env.version }} | ||
GH_TOKEN: ${{ secrets.GRAFANABOT_GITHUB_TOKEN }} | ||
run: | | ||
message="Update the loki-operator to $VERSION" | ||
body="Release loki-operator \`$VERSION\`. | ||
cc @periklis @xperimental @JoaoBraveCoding @btaani @shwetaap | ||
" | ||
branch="update-loki-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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.