-
Notifications
You must be signed in to change notification settings - Fork 59
51 lines (47 loc) · 2.02 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
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@v6
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.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@v3
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 "::set-output name=has_changes::$(if git diff --quiet && git diff --quiet --cached; then echo "false"; else echo "true"; fi)"
- name: Commit manifest changes
if: steps.helm_template.outputs.has_changes == 'true'
run: |
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 }}