Skip to content

Commit

Permalink
Support reporting to a PR from another repository
Browse files Browse the repository at this point in the history
Fixes #25
  • Loading branch information
lachaib committed Oct 16, 2023
1 parent 413a90b commit 51b1ce9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Available settings:
| ------------------------ | --------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| gh_access_token | | Token to access GH API. In most cases you can use GITHUB_TOKEN that is available in the workflow |
| report_path | 'reports' | Path to reports from the download artifact action |
| repository | ${{ github.repository }} | Repository containing the commit or pull request that triggered the tests |
| sha | ${{ github.sha }} | SHA of the commit that triggered the tests |
| pull_request_id | ${{ github.event.number }} | ID of the pull request that triggered pipeline |
| summary | 'true' | Add report to job summary |
Expand Down
15 changes: 12 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ inputs:
required: true
default: 'reports'
sha:
description: 'SHA of the commit tha triggered the tests'
description: 'SHA of the commit that triggered the tests'
required: false
default: "${{ github.sha }}"
repository:
description: 'Repository of the commit or pull request that triggered the tests'
required: false
default: "${{ github.repository }}"
pull_request_id:
description: 'ID of the Pull Request'
required: false
Expand All @@ -34,8 +38,13 @@ runs:
steps:
- shell: bash
run: |
export OWNER="$(echo "${{ github.repository }}" | awk -F / '{print $1}' | sed -e "s/:refs//")"
export REPO="$(echo "${{ github.repository }}" | awk -F / '{print $2}' | sed -e "s/:refs//")"
if [[ "${{ inputs.repository }}" =~ "/" ]]; then
export OWNER="$(echo "${{ inputs.repository }}" | awk -F / '{print $1}' | sed -e "s/:refs//")"
export REPO="$(echo "${{ inputs.repository }}" | awk -F / '{print $2}' | sed -e "s/:refs//")"
else
export OWNER="$(echo "${{ github.repository }}" | awk -F / '{print $1}' | sed -e "s/:refs//")"
export REPO="$(echo "${{ inputs.repository }}" | sed -e "s/:refs//")"
fi
echo "REPOSITORY_OWNER=$OWNER" >> $GITHUB_ENV
echo "REPOSITORY_NAME=$REPO" >> $GITHUB_ENV
- shell: bash
Expand Down

0 comments on commit 51b1ce9

Please sign in to comment.