Skip to content

Commit 9487245

Browse files
Extract action
1 parent 98d020a commit 9487245

File tree

2 files changed

+39
-28
lines changed

2 files changed

+39
-28
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Write File
2+
description: Writes a file with the given content
3+
4+
inputs:
5+
file-path:
6+
description: 'Path to the file to write.'
7+
required: true
8+
content:
9+
description: 'Content to write to the file.'
10+
required: true
11+
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Write Content to File
16+
shell: bash
17+
env:
18+
FILE_PATH: ${{ inputs.file-path }}
19+
CONTENT: ${{ inputs.content }}
20+
run: |
21+
mkdir -p "$(dirname "$FILE_PATH")"
22+
echo "$CONTENT" > "$FILE_PATH"
23+
echo "$CONTENT"

.github/workflows/build.yml

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,10 @@ jobs:
8080
- name: Select Java Version
8181
run: mise use java@21
8282
- name: Ensure Separate Job Cache Key
83-
shell: bash
84-
env:
85-
JOB_ID: ${{ github.job }}-${{ toJSON(matrix.item) }}
86-
run: |
87-
mkdir workaround
88-
echo "$JOB_ID" > workaround/pom.xml
89-
echo "$JOB_ID"
83+
uses: ./.github/actions/write-file
84+
with:
85+
file-path: just_for_cache_key_calculation/pom.xml
86+
content: ${{ github.job }}-${{ toJSON(matrix.item) }}
9087
- name: Configure Maven
9188
uses: SonarSource/ci-github-actions/config-maven@v1
9289
with:
@@ -150,13 +147,10 @@ jobs:
150147
- name: Select Java Version
151148
run: mise use java@21
152149
- name: Ensure Separate Job Cache Key
153-
shell: bash
154-
env:
155-
JOB_ID: ${{ github.job }}-${{ matrix.sq_version }}
156-
run: |
157-
mkdir workaround
158-
echo "$JOB_ID" > workaround/pom.xml
159-
echo "$JOB_ID"
150+
uses: ./.github/actions/write-file
151+
with:
152+
file-path: just_for_cache_/pom.xml
153+
content: ${{ github.job }}-${{ matrix.sq_version }}
160154
- name: Configure Maven
161155
uses: SonarSource/ci-github-actions/config-maven@v1
162156
with:
@@ -203,13 +197,10 @@ jobs:
203197
development/kv/data/next url | SONAR_HOST_URL;
204198
development/kv/data/next token | SONAR_TOKEN;
205199
- name: Ensure Separate Job Cache Key
206-
shell: bash
207-
env:
208-
JOB_ID: ${{ github.job }}
209-
run: |
210-
mkdir workaround
211-
echo "$JOB_ID" > workaround/pom.xml
212-
echo "$JOB_ID"
200+
uses: ./.github/actions/write-file
201+
with:
202+
file-path: just_for_cache_key_calculation/pom.xml
203+
content: ${{ github.job }}
213204
- uses: SonarSource/ci-github-actions/config-maven@v1
214205
with:
215206
artifactory-reader-role: private-reader
@@ -340,13 +331,10 @@ jobs:
340331
development/kv/data/next token | SONAR_TOKEN;
341332
development/github/token/licenses-ro token | GITHUB_TOKEN;
342333
- name: Ensure Separate Job Cache Key
343-
shell: bash
344-
env:
345-
JOB_ID: ${{ github.job }}
346-
run: |
347-
mkdir workaround
348-
echo "$JOB_ID" > workaround/pom.xml
349-
echo "$JOB_ID"
334+
uses: ./.github/actions/write-file
335+
with:
336+
file-path: just_for_cache_key_calculation/pom.xml
337+
content: ${{ github.job }}
350338
- uses: SonarSource/ci-github-actions/config-maven@v1
351339
with:
352340
artifactory-reader-role: private-reader

0 commit comments

Comments
 (0)