Skip to content

Commit 54873d7

Browse files
authored
Merge pull request #443 from element-hq/bbz/dyff-job-runner-temp
Use $RUNNER_TEMP rather than hard-coding our own temp directory
2 parents bb30b61 + bb5e11e commit 54873d7

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

.github/workflows/build-test.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
name: Helm Chart Building tests
66
on:
7-
pull_request_target:
7+
pull_request:
88
push:
99
branches:
1010
- main
@@ -101,7 +101,6 @@ jobs:
101101
contents: read
102102
pull-requests: write # required to post a comment to a pull request
103103
steps:
104-
105104
- name: Checkout PR
106105
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
107106
with:
@@ -110,13 +109,13 @@ jobs:
110109
# helm template doesn't reliably order manifests within the same kind, so use yq to do it for us
111110
- name: Generate manifests for PR
112111
run: |
113-
mkdir -p /tmp/{old,new}
112+
mkdir -p "$RUNNER_TEMP/new"
114113
for values in charts/matrix-stack/ci/*values.yaml; do
115114
echo "Generating new templates with $values";
116115
helm template \
117116
-a monitoring.coreos.com/v1/ServiceMonitor \
118117
-f "$values" charts/matrix-stack | \
119-
yq ea '[.] | sort_by(.kind, .metadata.name) | .[] | splitDoc' > "/tmp/new/$(basename "$values")"
118+
yq ea '[.] | sort_by(.kind, .metadata.name) | .[] | splitDoc' > "$RUNNER_TEMP/new/$(basename "$values")"
120119
done
121120
122121
- name: Checkout target
@@ -126,12 +125,13 @@ jobs:
126125

127126
- name: Generate manifests for base
128127
run: |
128+
mkdir -p "$RUNNER_TEMP/old"
129129
for values in charts/matrix-stack/ci/*values.yaml; do
130130
echo "Generating old templates with $values";
131131
helm template \
132132
-a monitoring.coreos.com/v1/ServiceMonitor \
133133
-f "$values" charts/matrix-stack | \
134-
yq ea '[.] | sort_by(.kind, .metadata.name) | .[] | splitDoc' > "/tmp/old/$(basename "$values")"
134+
yq ea '[.] | sort_by(.kind, .metadata.name) | .[] | splitDoc' > "$RUNNER_TEMP/old/$(basename "$values")"
135135
done
136136
137137
- name: Install dyff with asdf
@@ -145,24 +145,25 @@ jobs:
145145
146146
- name: dyff old and new manifests
147147
id: dyff
148+
shell: bash
148149
run: |
149-
templates_files=$(find /tmp/old /tmp/new -maxdepth 1 -name '*values.yaml' | sed -E 's|/tmp/(old\|new)/||' | sort | uniq)
150+
templates_files=$(find "$RUNNER_TEMP/old" "$RUNNER_TEMP/new" -maxdepth 1 -name '*values.yaml' | sed -E 's|'"$RUNNER_TEMP"'/(old\|new)/||' | sort | uniq)
150151
151152
header="# dyff of changes in rendered templates of CI manifests\n\n"
152153
comment_body=""
153154
while read -r templates_file; do
154-
if [ ! -f "/tmp/old/$templates_file" ]; then
155+
if [ ! -f "$RUNNER_TEMP/old/$templates_file" ]; then
155156
comment_body+="**$templates_file** (added)\n\n"
156157
continue
157158
fi
158159
159-
if [ ! -f "/tmp/new/$templates_file" ]; then
160+
if [ ! -f "$RUNNER_TEMP/new/$templates_file" ]; then
160161
comment_body+="**$templates_file** (removed)\n\n"
161162
continue
162163
fi
163164
164165
exit_code=0
165-
dyff_detail=$(dyff between --set-exit-code --omit-header --output=github "/tmp/old/$templates_file" "/tmp/new/$templates_file") || exit_code=$?
166+
dyff_detail=$(dyff between --set-exit-code --omit-header --output=github "$RUNNER_TEMP/old/$templates_file" "$RUNNER_TEMP/new/$templates_file") || exit_code=$?
166167
if [ $exit_code -ne 0 ]; then
167168
comment_body+="<details><summary><b>$templates_file</b> (changed)</summary>\n"
168169
comment_body+='\n```diff\n'
@@ -175,7 +176,7 @@ jobs:
175176
comment_body="No changes in rendered templates"
176177
fi
177178
178-
echo -e "$header$comment_body" | tee "/tmp/dyff-output"
179+
echo -e "$header$comment_body" | tee "$RUNNER_TEMP/dyff-output"
179180
180181
- name: Find dyff comment
181182
if: github.event.pull_request.number != ''
@@ -192,5 +193,5 @@ jobs:
192193
with:
193194
comment-id: ${{ steps.find-dyff-comment.outputs.comment-id }}
194195
issue-number: ${{ github.event.pull_request.number }}
195-
body-path: /tmp/dyff-output
196+
body-path: ${{ runner.temp }}/dyff-output
196197
edit-mode: replace
File renamed without changes.

0 commit comments

Comments
 (0)