ci: handle files with same name in ci comment workflow

This commit is contained in:
Nick Bolton 2024-09-23 01:20:31 +01:00
parent 1bfdb8f707
commit b1da95757b

View file

@ -27,40 +27,32 @@ jobs:
with: with:
run-id: ${{ github.event.workflow_run.id }} run-id: ${{ github.event.workflow_run.id }}
pattern: summary-* pattern: summary-*
merge-multiple: true
path: summaries path: summaries
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get workflow URL
id: workflow-url
run: |
repo_url="${{ github.server_url }}/${{ github.repository }}"
echo "url=$repo_url/actions/runs/${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
shell: bash
- name: Merge summaries - name: Merge summaries
id: summary id: summary
run: | run: |
dir="summaries" ls -R
if [ ! -d "$dir" ]; then
echo "Skipping, no summaries, no such dir: $dir"
exit 0
fi
files=$(ls $dir) files=$(find $dir -type f)
if [ -z "$files" ]; then if [ -z "$files" ]; then
echo "Error: No summaries found in dir: $dir" echo "No files found in dir: $dir"
exit 1 exit 0
fi fi
echo "message<<EOF" >> $GITHUB_OUTPUT echo "message<<EOF" >> $GITHUB_OUTPUT
echo "## CI Summary" >> $GITHUB_OUTPUT echo "## CI Summary" >> $GITHUB_OUTPUT
for file in $dir/*; do for file in $files; do
echo $(cat $file) >> $GITHUB_OUTPUT echo $(cat $file) >> $GITHUB_OUTPUT
done done
echo "[Full summary](${{ steps.workflow-url.outputs.url }})" >> $GITHUB_OUTPUT repo_url="${{ github.server_url }}/${{ github.repository }}"
run_url="$repo_url/actions/runs/${{ github.event.workflow_run.id }}"
echo > $GITHUB_OUTPUT
echo "[Full summary]($run_url)" (scroll down) >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT
- name: Set PR comment - name: Set PR comment