Skip to content

Commit 917a326

Browse files
committed
Refactor retention days logic in main.yml to use a dedicated step for better clarity and maintainability.
1 parent e38450f commit 917a326

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,20 +179,29 @@ jobs:
179179
coverage html
180180
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
181181
182+
- name: Determine retention days
183+
id: determine-retention-days
184+
run: |
185+
if [ "${{ github.ref }}" = "refs/heads/main" ] || [[ "${{ github.ref }}" == refs/tags/* ]]; then
186+
echo "retention_days=90" >> $GITHUB_OUTPUT
187+
else
188+
echo "retention_days=3" >> $GITHUB_OUTPUT
189+
fi
190+
182191
- name: Upload combined .coverage file
183192
uses: actions/upload-artifact@v4
184193
with:
185194
name: coverage-file
186195
path: .coverage
187-
retention-days: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && 90 || 3 }}
196+
retention-days: ${{ steps.determine-retention-days.outputs.retention_days }}
188197
include-hidden-files: true
189198

190199
- name: Upload HTML coverage report
191200
uses: actions/upload-artifact@v4
192201
with:
193202
name: coverage-html-report
194203
path: htmlcov
195-
retention-days: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) && 90 || 3 }}
204+
retention-days: ${{ steps.determine-retention-days.outputs.retention_days }}
196205

197206
- name: Delete temporary coverage artifacts from run
198207
uses: geekyeggo/delete-artifact@v5

0 commit comments

Comments
 (0)