2
0

fips-label.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Changed Label
  8. on:
  9. workflow_run:
  10. workflows: ["FIPS Checksums"]
  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 artifact'
  24. if: ${{ github.event.workflow_run.conclusion == 'success' }}
  25. uses: actions/github-script@v4
  26. with:
  27. script: |
  28. var artifacts = await github.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.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@v4
  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.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.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.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. }