action.yml 1.7 KB

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