Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 40 additions & 5 deletions .github/workflows/operator-hub-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Copy link
Copy Markdown
Contributor

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?

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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:
Expand All @@ -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
Expand All @@ -65,6 +98,7 @@ jobs:

- name: Copy bundle to versioned directory
run: |
VERSION="${{ steps.prepare_release.outputs.version }}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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}/
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-operator-hub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
with:
org: k8s-operatorhub
repo: community-operators
release_ref: ${{ github.event.release.tag_name }}
secrets:
# NOTE: BOT_TOKEN is a PAT (repo scope) for the persesbot account
# Required to sync and push to persesbot's fork of community-operators
Expand Down
Loading