Skip to content

feat: handle correctly when replica count is set to 0 #587

feat: handle correctly when replica count is set to 0

feat: handle correctly when replica count is set to 0 #587

name: Manifest
on:
issue_comment:
types: [created, edited]
jobs:
sync-chart-manifest-on-comment:
if: contains(github.event.comment.body, '@meilisearch sync-manifest')
name: Sync chart manifest on comment
runs-on: ubuntu-latest
steps:
# There isn't enough detail in the github.event on "issue_comment" events about the PR origin, so we need to fetch more
- name: "Get Pull Request"
uses: actions/github-script@v7
id: get-pr
with:
script: |
const request = {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
}
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
try {
const result = await github.rest.pulls.get(request)
return result.data
} catch (err) {
core.setFailed(`Request failed with error ${err}`)
}
# Now checkout the PR, generate the template and then commit to the PR
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
- name: Run helm template
id: helm_template
run: |
helm template meilisearch charts/meilisearch | grep -v 'helm.sh/chart:\|app.kubernetes.io/managed-by:' > manifests/meilisearch.yaml
echo "has_changes=$(if git diff --quiet && git diff --quiet --cached; then echo "false"; else echo "true"; fi)" >> "$GITHUB_ENV"
- name: Commit manifest changes
run: |
if [[ $has_changes == "true" ]]; then
echo "There are changes in the Git working directory."
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add .
git commit -m "[CI] Syncing Helm manifest"
git push --set-upstream origin ${{ fromJSON(steps.get-pr.outputs.result).head.ref }}
else
echo "No changes in the Git working directory."
fi