-
Notifications
You must be signed in to change notification settings - Fork 59
58 lines (51 loc) · 2.17 KB
/
update-chart-manifest.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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