2
0

fips-label.yml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License 2.0 (the "License"). You may not use
  4. # this file except in compliance with the License. You can obtain a copy
  5. # in the file LICENSE in the source distribution or at
  6. # https://www.openssl.org/source/license.html
  7. name: FIPS and ABI Changed Label
  8. on:
  9. workflow_run:
  10. workflows: ["FIPS Check and ABIDIFF"]
  11. types:
  12. - completed
  13. permissions:
  14. contents: read
  15. jobs:
  16. apply-label:
  17. permissions:
  18. actions: read
  19. pull-requests: write
  20. runs-on: ubuntu-latest
  21. if: ${{ github.event.workflow_run.event == 'pull_request' }}
  22. steps:
  23. - name: 'Download fipscheck artifact'
  24. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  25. uses: actions/github-script@v7
  26. with:
  27. script: |
  28. var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
  29. owner: context.repo.owner,
  30. repo: context.repo.repo,
  31. run_id: ${{github.event.workflow_run.id }},
  32. });
  33. var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  34. return artifact.name == "fips_checksum"
  35. })[0];
  36. var download = await github.rest.actions.downloadArtifact({
  37. owner: context.repo.owner,
  38. repo: context.repo.repo,
  39. artifact_id: matchArtifact.id,
  40. archive_format: 'zip',
  41. });
  42. var fs = require('fs');
  43. fs.writeFileSync('${{github.workspace}}/artifact.zip', Buffer.from(download.data));
  44. - run: unzip artifact.zip
  45. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  46. - name: 'Check artifact and apply'
  47. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  48. uses: actions/github-script@v7
  49. with:
  50. github-token: ${{secrets.GITHUB_TOKEN}}
  51. script: |
  52. var fs = require('fs');
  53. var pr_num = Number(fs.readFileSync('./pr_num'));
  54. if ( fs.existsSync('./fips_changed') ) {
  55. github.rest.issues.addLabels({
  56. issue_number: pr_num,
  57. owner: context.repo.owner,
  58. repo: context.repo.repo,
  59. labels: ['severity: fips change']
  60. });
  61. } else if ( fs.existsSync('./fips_unchanged') ) {
  62. var labels = await github.rest.issues.listLabelsOnIssue({
  63. issue_number: pr_num,
  64. owner: context.repo.owner,
  65. repo: context.repo.repo
  66. });
  67. for ( var label in labels.data ) {
  68. if (labels.data[label].name == 'severity: fips change') {
  69. github.rest.issues.removeLabel({
  70. issue_number: pr_num,
  71. owner: context.repo.owner,
  72. repo: context.repo.repo,
  73. name: 'severity: fips change'
  74. });
  75. }
  76. }
  77. }
  78. - name: 'Cleanup artifact'
  79. run: rm artifact.zip pr_num
  80. - name: 'Download abidiff artifact'
  81. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  82. uses: actions/github-script@v7
  83. with:
  84. script: |
  85. var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
  86. owner: context.repo.owner,
  87. repo: context.repo.repo,
  88. run_id: ${{github.event.workflow_run.id }},
  89. });
  90. var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
  91. return artifact.name == "abidiff"
  92. })[0];
  93. var download = await github.rest.actions.downloadArtifact({
  94. owner: context.repo.owner,
  95. repo: context.repo.repo,
  96. artifact_id: matchArtifact.id,
  97. archive_format: 'zip',
  98. });
  99. var fs = require('fs');
  100. fs.writeFileSync('${{github.workspace}}/artifact.zip', Buffer.from(download.data));
  101. - run: unzip artifact.zip
  102. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  103. - name: 'Check artifact and apply'
  104. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  105. uses: actions/github-script@v7
  106. with:
  107. github-token: ${{secrets.GITHUB_TOKEN}}
  108. script: |
  109. var fs = require('fs');
  110. var pr_num = Number(fs.readFileSync('./pr_num'));
  111. if ( fs.existsSync('./abi_changed') ) {
  112. github.rest.issues.addLabels({
  113. issue_number: pr_num,
  114. owner: context.repo.owner,
  115. repo: context.repo.repo,
  116. labels: ['severity: ABI change']
  117. });
  118. } else if ( fs.existsSync('./abi_unchanged') ) {
  119. var labels = await github.rest.issues.listLabelsOnIssue({
  120. issue_number: pr_num,
  121. owner: context.repo.owner,
  122. repo: context.repo.repo
  123. });
  124. for ( var label in labels.data ) {
  125. if (labels.data[label].name == 'severity: ABI change') {
  126. github.rest.issues.removeLabel({
  127. issue_number: pr_num,
  128. owner: context.repo.owner,
  129. repo: context.repo.repo,
  130. name: 'severity: fips change'
  131. });
  132. }
  133. }
  134. }