github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/.github/workflows/trusted.yml (about) 1 on: 2 workflow_run: 3 workflows: ["apidiff"] 4 types: 5 - completed 6 7 permissions: 8 pull-requests: write 9 10 jobs: 11 tag-breaking-change: 12 name: Tag breaking changes 13 runs-on: ubuntu-latest 14 if: github.event.workflow_run.event == 'pull_request' 15 steps: 16 - name: 'Download artifact' 17 uses: actions/github-script@v7 18 with: 19 script: | 20 var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ 21 owner: context.repo.owner, 22 repo: context.repo.repo, 23 run_id: ${{github.event.workflow_run.id }}, 24 }); 25 var matchArtifact = artifacts.data.artifacts.filter((artifact) => { 26 return artifact.name == "apidiff" 27 })[0]; 28 var download = await github.rest.actions.downloadArtifact({ 29 owner: context.repo.owner, 30 repo: context.repo.repo, 31 artifact_id: matchArtifact.id, 32 archive_format: 'zip', 33 }); 34 var fs = require('fs'); 35 fs.writeFileSync('${{github.workspace}}/apidiff.zip', Buffer.from(download.data)); 36 - run: unzip apidiff.zip 37 - name: 'Add or remove label' 38 uses: actions/github-script@v7 39 with: 40 github-token: ${{ secrets.GITHUB_TOKEN }} 41 script: | 42 var fs = require('fs'); 43 var jsonData = JSON.parse(fs.readFileSync('apidiff.json', 'utf8')); 44 45 var issueNumber = jsonData.id; 46 var semverType = jsonData["semver-type"]; 47 48 if (semverType === 'major') { 49 // Add 'breaking-change' label 50 await github.rest.issues.addLabels({ 51 owner: context.repo.owner, 52 repo: context.repo.repo, 53 issue_number: issueNumber, 54 labels: ['breaking-change'] 55 }); 56 } else { 57 // Remove 'breaking-change' label if it exists 58 try { 59 await github.rest.issues.removeLabel({ 60 owner: context.repo.owner, 61 repo: context.repo.repo, 62 issue_number: issueNumber, 63 name: 'breaking-change' 64 }); 65 } catch (error) { 66 console.log('Label breaking-change not found or already removed'); 67 } 68 }