Skip to content

Commit

Permalink
add pr_comment.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
bennibbelink committed Feb 12, 2024
1 parent 24c35a4 commit 09d6bec
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 12 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,29 @@ jobs:
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=ci-tag@${{ steps.build-cycamore.outputs.digest }}
- name: PR Comment
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v2
- name: Export Environment Variables
if: github.event_name == 'pull_request'
run: |
echo "CYCAMORE_BUILD_STATUS=${{steps.build-cycamore.outcome == 'success' && '**Success** :white_check_mark:' ||
steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV"
echo "CYMETRIC_BUILD_STATUS=${{steps.build-cymetric.outcome == 'success' && '**Success** :white_check_mark:' ||
steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV"
echo "ARTIFACT_NAME=${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cyclus_tag }}" >> "$GITHUB_ENV"
- name: Construct Artifact
if: github.event_name == 'pull_request'
run: |
echo "Build \`FROM cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cyclus:${{ matrix.cyclus }}\`
- Cycamore: ${{ env.CYCAMORE_BUILD_STATUS }}
- Cymetric: ${{ env.CYMETRIC_BUILD_STATUS }}" > ${{ env.ARTIFACT_NAME }}.txt
- name: Upload Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
comment_tag: ${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cyclus_tag }}
message: |
## Build statuses using cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}:${{ matrix.cyclus_tag }}
- Cycamore: ${{steps.build-cycamore.outcome == 'success' && '*Success* :white_check_mark:' ||
steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}
- Cymetric: ${{steps.build-cymetric.outcome == 'success' && '*Success* :white_check_mark:' ||
steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.txt
32 changes: 32 additions & 0 deletions .github/workflows/pr_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Comment on PR

on:
workflow_run:
workflows: ["Build/Test for PR and collaborator push"]
types:
- completed

jobs:
pr-comment:
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
merge-multiple: true

- name: Merge artifacts and get PR number
run: |
echo "### Build Status Report" > artifacts_merged.md
cat ./*.txt >> artifacts_merged.md
echo "PR_NUMBER=$(cat pr_number)" >> "$GITHUB_ENV"
- name: PR Comment
uses: thollander/actions-comment-pull-request@v2
with:
pr_number: ${{ env.PR_NUMBER }}
comment_tag: build_status_report
filePath: artifacts_merged.md

0 comments on commit 09d6bec

Please sign in to comment.