ReportDiff.ps1 889 B

1234567891011121314151617181920212223242526272829
  1. # Check the code is in sync
  2. $changed = (select-string "nothing to commit" artifacts\status.txt).count -eq 0
  3. if (-not $changed) { return $changed }
  4. # Check if tracking issue is open/closed
  5. $Headers = @{ Authorization = 'token {0}' -f $ENV:GITHUB_TOKEN; };
  6. $result = Invoke-RestMethod -Uri $issue
  7. if ($result.state -eq "closed") {
  8. $json = "{ `"state`": `"open`" }"
  9. $result = Invoke-RestMethod -Method PATCH -Headers $Headers -Uri $issue -Body $json
  10. }
  11. # Add a comment
  12. $status = [IO.File]::ReadAllText("artifacts\status.txt")
  13. $diff = [IO.File]::ReadAllText("artifacts\diff.txt")
  14. $body = @"
  15. The shared code is out of sync.
  16. <details>
  17. <summary>The Diff</summary>
  18. ``````
  19. $status
  20. $diff
  21. ``````
  22. </details>
  23. "@
  24. $json = ConvertTo-Json -InputObject @{ 'body' = $body }
  25. $issue = $issue + '/comments'
  26. $result = Invoke-RestMethod -Method POST -Headers $Headers -Uri $issue -Body $json
  27. return $changed