fips-label.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. name: FIPS Changed Label
  2. on:
  3. workflow_run:
  4. workflows: ["FIPS Checksums"]
  5. types:
  6. - completed
  7. jobs:
  8. apply-label:
  9. runs-on: ubuntu-latest
  10. if: ${{ github.event.workflow_run.event == 'pull_request' }}
  11. steps:
  12. - name: 'Download artifact'
  13. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  14. uses: actions/github-script@v4
  15. with:
  16. script: |
  17. var artifacts = await github.actions.listWorkflowRunArtifacts({
  18. owner: context.repo.owner,
  19. repo: context.repo.repo,
  20. run_id: ${{github.event.workflow_run.id }},
  21. });
  22. var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  23. return artifact.name == "fips_checksum"
  24. })[0];
  25. var download = await github.actions.downloadArtifact({
  26. owner: context.repo.owner,
  27. repo: context.repo.repo,
  28. artifact_id: matchArtifact.id,
  29. archive_format: 'zip',
  30. });
  31. var fs = require('fs');
  32. fs.writeFileSync('${{github.workspace}}/artifact.zip', Buffer.from(download.data));
  33. - run: unzip artifact.zip
  34. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  35. - name: 'Check artifact and apply'
  36. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  37. uses: actions/github-script@v4
  38. with:
  39. github-token: ${{secrets.GITHUB_TOKEN}}
  40. script: |
  41. var fs = require('fs');
  42. var pr_num = Number(fs.readFileSync('./pr_num'));
  43. if ( fs.existsSync('./fips_changed') ) {
  44. github.issues.addLabels({
  45. issue_number: pr_num,
  46. owner: context.repo.owner,
  47. repo: context.repo.repo,
  48. labels: ['severity: fips change']
  49. });
  50. } else if ( fs.existsSync('./fips_unchanged') ) {
  51. var labels = await github.issues.listLabelsOnIssue({
  52. issue_number: pr_num,
  53. owner: context.repo.owner,
  54. repo: context.repo.repo
  55. });
  56. for ( var label in labels.data ) {
  57. if (labels.data[label].name == 'severity: fips change') {
  58. github.issues.removeLabel({
  59. issue_number: pr_num,
  60. owner: context.repo.owner,
  61. repo: context.repo.repo,
  62. name: 'severity: fips change'
  63. });
  64. }
  65. }
  66. }