Skip to content

Commit 42195df

Browse files
committed
Remove maintainers, cleanup indentation
Narrow readme update trigger Create Preview README changes workflow Test against PR ref not HEAD Fix README render location More backtics for codefence Fetch diff from env Try a non relative path Try a different location for README
1 parent aac0c2e commit 42195df

File tree

6 files changed

+145
-99
lines changed

6 files changed

+145
-99
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Preview README changes
2+
run-name: Preview README changes for ${{ github.ref_name }} by @${{ github.actor }}
3+
on:
4+
pull_request:
5+
paths:
6+
- charts/s3proxy/Chart.yaml
7+
- charts/s3proxy/values.yaml
8+
- README.md.gotmpl
9+
- README.md
10+
11+
jobs:
12+
preview-readme:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 5
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.event.pull_request.head.ref }}
19+
20+
- name: Save HEAD SHA before helm-docs
21+
id: save-sha
22+
run: |
23+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
24+
25+
- name: Render helm docs inside the README.md
26+
uses: losisin/helm-docs-github-action@v1
27+
with:
28+
git-push: false
29+
output-file: ../../README.md
30+
template-files: README.md.gotmpl
31+
32+
- name: Check for README changes
33+
id: check-changes
34+
run: |
35+
if git diff --quiet ${{ steps.save-sha.outputs.sha }} -- README.md
36+
then
37+
echo "has_changes=false" >> $GITHUB_OUTPUT
38+
else
39+
echo "has_changes=true" >> $GITHUB_OUTPUT
40+
fi
41+
42+
- name: Generate diff
43+
id: diff
44+
if: steps.check-changes.outputs.has_changes == 'true'
45+
run: |
46+
echo 'diff<<EOF' >> $GITHUB_OUTPUT
47+
git diff ${{ steps.save-sha.outputs.sha }} -- README.md >> $GITHUB_OUTPUT
48+
echo 'EOF' >> $GITHUB_OUTPUT
49+
50+
- name: Find and hide outdated comments
51+
if: steps.check-changes.outputs.has_changes == 'true'
52+
uses: actions/github-script@v7
53+
with:
54+
github-token: ${{ secrets.GITHUB_TOKEN }}
55+
script: |
56+
const comments = await github.rest.issues.listComments({
57+
owner: context.repo.owner,
58+
repo: context.repo.repo,
59+
issue_number: context.issue.number
60+
});
61+
62+
const botComments = comments.data.filter(comment =>
63+
comment.user.type === 'Bot' &&
64+
comment.body.includes('<!-- helm-docs-preview -->')
65+
);
66+
67+
for (const comment of botComments) {
68+
await github.graphql(`
69+
mutation {
70+
minimizeComment(input: {
71+
subjectId: "${comment.node_id}",
72+
classifier: OUTDATED
73+
}) {
74+
clientMutationId
75+
}
76+
}
77+
`);
78+
}
79+
80+
- name: Post README changes as comment
81+
if: steps.check-changes.outputs.has_changes == 'true'
82+
uses: actions/github-script@v7
83+
env:
84+
DIFF_CONTENT: ${{ steps.diff.outputs.diff }}
85+
with:
86+
github-token: ${{ secrets.GITHUB_TOKEN }}
87+
script: |
88+
// Get the diff from the environment variable to avoid JavaScript syntax issues
89+
const diff = process.env.DIFF_CONTENT;
90+
91+
// Use 4 backticks for the outer fence to safely contain any triple backticks in the diff
92+
const body = `<!-- helm-docs-preview -->
93+
## 📝 README.md Preview
94+
95+
The following changes to \`README.md\` will be applied when this PR is merged:
96+
97+
<details>
98+
<summary>Click to expand diff</summary>
99+
100+
\`\`\`\`diff
101+
${diff}
102+
\`\`\`\`
103+
104+
</details>
105+
106+
> **Note**: This is an automated preview generated by \`helm-docs\`. The changes will be automatically applied upon merge.`;
107+
108+
await github.rest.issues.createComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
issue_number: context.issue.number,
112+
body: body
113+
});
114+
115+
- name: Hide outdated comments when no changes
116+
if: steps.check-changes.outputs.has_changes == 'false'
117+
uses: actions/github-script@v7
118+
with:
119+
github-token: ${{ secrets.GITHUB_TOKEN }}
120+
script: |
121+
const comments = await github.rest.issues.listComments({
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
issue_number: context.issue.number
125+
});
126+
127+
const botComments = comments.data.filter(comment =>
128+
comment.user.type === 'Bot' &&
129+
comment.body.includes('<!-- helm-docs-preview -->')
130+
);
131+
132+
for (const comment of botComments) {
133+
await github.graphql(`
134+
mutation {
135+
minimizeComment(input: {
136+
subjectId: "${comment.node_id}",
137+
classifier: OUTDATED
138+
}) {
139+
clientMutationId
140+
}
141+
}
142+
`);
143+
}

.github/workflows/update-readme.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ on:
55
branches:
66
- main
77
paths:
8-
- charts/s3proxy/**
8+
- charts/s3proxy/Chart.yaml
9+
- charts/s3proxy/values.yaml
910
- README.md.gotmpl
1011
- README.md
1112

charts/s3proxy/Chart.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
apiVersion: v2
22
name: s3proxy
33
description: A Helm chart for deploying S3Proxy - Access other storage backends via the S3 API
4-
maintainers:
5-
- name: CRThaze
64

75
# A chart can be either an 'application' or a 'library' chart.
86
#

charts/s3proxy/README.md

Lines changed: 0 additions & 95 deletions
This file was deleted.

charts/s3proxy/values.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ ingress:
6969
# - chart-example.local
7070

7171
# -- Resource limits and requests
72-
# @default -- `{}`
7372
resources: {}
7473
# We usually recommend not to specify default resources and to leave this as a conscious
7574
# choice for the user. This also increases chances charts run on environments with little

0 commit comments

Comments
 (0)