action.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. name: Compare gas costs
  2. inputs:
  3. token:
  4. description: github token
  5. required: true
  6. report:
  7. description: report to read from
  8. required: false
  9. default: gasReporterOutput.json
  10. out_report:
  11. description: report to read
  12. required: false
  13. default: ${{ github.ref_name }}.gasreport.json
  14. ref_report:
  15. description: report to read from
  16. required: false
  17. default: ${{ github.base_ref }}.gasreport.json
  18. runs:
  19. using: composite
  20. steps:
  21. - name: Download reference report
  22. if: github.event_name == 'pull_request'
  23. run: |
  24. RUN_ID=`gh run list --repo ${{ github.repository }} --branch ${{ github.base_ref }} --workflow ${{ github.workflow }} --limit 100 --json 'conclusion,databaseId,event' --jq 'map(select(.conclusion=="success" and .event!="pull_request"))[0].databaseId'`
  25. gh run download ${RUN_ID} --repo ${{ github.repository }} -n gasreport
  26. env:
  27. GITHUB_TOKEN: ${{ inputs.token }}
  28. shell: bash
  29. continue-on-error: true
  30. id: reference
  31. - name: Compare reports
  32. if: steps.reference.outcome == 'success' && github.event_name == 'pull_request'
  33. run: |
  34. node scripts/checks/compareGasReports.js ${{ inputs.report }} ${{ inputs.ref_report }} >> $GITHUB_STEP_SUMMARY
  35. env:
  36. STYLE: markdown
  37. shell: bash
  38. - name: Rename report for upload
  39. if: github.event_name != 'pull_request'
  40. run: |
  41. mv ${{ inputs.report }} ${{ inputs.out_report }}
  42. shell: bash
  43. - name: Save report
  44. if: github.event_name != 'pull_request'
  45. uses: actions/upload-artifact@v3
  46. with:
  47. name: gasreport
  48. path: ${{ inputs.out_report }}