-
Notifications
You must be signed in to change notification settings - Fork 22
[IGNORE] Add workflow_dispatch for operatorhub release and enforce tag-only refs #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,28 @@ on: | |
| repo: | ||
| type: string | ||
| required: true | ||
| release_ref: | ||
| type: string | ||
| required: true | ||
| secrets: | ||
| BOT_TOKEN: | ||
| required: true | ||
| workflow_dispatch: | ||
| inputs: | ||
| org: | ||
| description: Organization that owns the target repository | ||
| required: true | ||
| type: string | ||
| default: k8s-operatorhub | ||
| repo: | ||
| description: Target repository name | ||
| required: true | ||
| type: string | ||
| default: community-operators | ||
| release_ref: | ||
| description: Release tag to publish from (for example v0.4.0) | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
@@ -26,12 +45,26 @@ jobs: | |
| contents: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Set version from tag | ||
| - name: Validate and prepare release values | ||
| id: prepare_release | ||
| env: | ||
| TAG: ${{ github.ref_name }} | ||
| RELEASE_REF_INPUT: ${{ inputs.release_ref }} | ||
| run: | | ||
| TAG=${TAG:1} | ||
| echo "VERSION=${TAG}" >> $GITHUB_ENV | ||
| TAG="${RELEASE_REF_INPUT#refs/tags/}" | ||
| VERSION="${TAG#v}" | ||
|
|
||
| if [ -z "${TAG}" ]; then | ||
| echo "A release tag is required. Pass release_ref (for example v0.4.0)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! git ls-remote --exit-code --tags "https://github.com/${GITHUB_REPOSITORY}.git" "refs/tags/${TAG}" >/dev/null; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this failure can also be that the repo is unreachable, networking error for example. But the error message will still say the tag does not exist... |
||
| echo "release_ref must be an existing tag in ${GITHUB_REPOSITORY}: ${TAG}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "release_ref=${TAG}" >> "$GITHUB_OUTPUT" | ||
| echo "version=${VERSION}" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Sync fork | ||
| env: | ||
|
|
@@ -51,7 +84,7 @@ jobs: | |
| uses: actions/checkout@v6 | ||
| with: | ||
| repository: ${{ github.repository }} | ||
| ref: ${{ github.ref_name }} | ||
| ref: ${{ steps.prepare_release.outputs.release_ref }} | ||
| path: tmp/ | ||
|
|
||
| - name: Set up Go | ||
|
|
@@ -65,6 +98,7 @@ jobs: | |
|
|
||
| - name: Copy bundle to versioned directory | ||
| run: | | ||
| VERSION="${{ steps.prepare_release.outputs.version }}" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we use env like in line 111? |
||
| mkdir -p operators/${OPERATOR_NAME}/${VERSION} | ||
| cp -R tmp/bundle/manifests operators/${OPERATOR_NAME}/${VERSION}/ | ||
| cp -R tmp/bundle/metadata operators/${OPERATOR_NAME}/${VERSION}/ | ||
|
|
@@ -74,6 +108,7 @@ jobs: | |
| - name: Create pull request | ||
| env: | ||
| GH_TOKEN: ${{ secrets.BOT_TOKEN }} | ||
| VERSION: ${{ steps.prepare_release.outputs.version }} | ||
| run: | | ||
| git config user.name ${{ env.BOT_USER }} | ||
| git config user.email ${{ env.BOT_USER }}@users.noreply.github.com | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we are trying to check if this is empty, but this always has content even if RELEASE_REF_INPUT is empty, right?