Skip to content

Commit

Permalink
Add ability to pass output to another step
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Feb 2, 2020
1 parent 0b636de commit 1dc31b9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ jobs:
uses: ./
with:
url: 'https://github.com/'
id: lighthouse
- name: Comment output on PR
if: github.event_name == 'pull_request'
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Here is your Lighthouse score:\n
\n
Performance: ${{ steps.lighthouse.outputs.performance }}\n
Accessibility: ${{ steps.lighthouse.outputs.accessibility }}\n
Best Practices: ${{ steps.lighthouse.outputs.practices }}\n
SEO: ${{ steps.lighthouse.outputs.seo }}\n
PWA: ${{ steps.lighthouse.outputs.pwa }}\n"
- uses: actions/upload-artifact@master
with:
name: report
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ jobs:

On pull requests, the PR number will be extracted from the GitHub event data and used to generate the deploy preview URL as follows: `https://deploy-preview-[[PR_NUMBER]]--[[NETLIFY_SITE]].netlify.com`. You can combine the two above examples and include both `url` and `netlify_site` and run on `on: [push, pull_request]` and the appropriate URL will be automatically selected depending on the type of event.

### Comment output on PR

Extends the previous

```yaml
...
jobs:
audit:
runs-on: ubuntu-latest
steps:
- name: Audit live URL
uses: jakejarvis/lighthouse-action@master
with:
url: 'https://jarv.is/'
id: lighthouse
- name: Comment output on PR
uses: unsplash/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: "Performance: ${{ steps.lighthouse.outputs.performance }}"
```

## To-Do

Expand Down
7 changes: 7 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,11 @@ printf "* Detailed results are saved here, use https://github.com/actions/upload
printf " %s\n" "$OUTPUT_PATH.report.html"
printf " %s\n" "$OUTPUT_PATH.report.json"

# Print scores, so they can be used in another action step.
echo "##[set-output name=performance;]$(echo "$SCORE_PERFORMANCE*100" | bc -l)"
echo "##[set-output name=accessibility;]$(echo "$SCORE_ACCESSIBILITY*100" | bc -l)"
echo "##[set-output name=practices;]$(echo "$SCORE_PRACTICES*100" | bc -l)"
echo "##[set-output name=seo;]$(echo "$SCORE_SEO*100" | bc -l)"
echo "##[set-output name=pwa;]$(echo "$SCORE_PWA*100" | bc -l)"

exit 0

0 comments on commit 1dc31b9

Please sign in to comment.