1name: (Shared) Check maintainer23on:4 workflow_call:5 inputs:6 actor:7 required: true8 type: string9 outputs:10 is_core_team:11 value: ${{ jobs.check_maintainer.outputs.is_core_team }}1213permissions: {}1415env:16 TZ: /usr/share/zoneinfo/America/Los_Angeles17 # https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout18 SEGMENT_DOWNLOAD_TIMEOUT_MINS: 11920jobs:21 check_maintainer:22 runs-on: ubuntu-latest23 permissions:24 # We fetch the contents of the MAINTAINERS file25 contents: read26 outputs:27 is_core_team: ${{ steps.check_if_actor_is_maintainer.outputs.result }}28 steps:29 - name: Check if actor is maintainer30 id: check_if_actor_is_maintainer31 uses: actions/github-script@v732 with:33 script: |34 const fs = require('fs');35 const actor = '${{ inputs.actor }}';36 const res = await github.rest.repos.getContent({37 owner: 'facebook',38 repo: 'react',39 path: 'MAINTAINERS',40 ref: 'main',41 headers: { Accept: 'application/vnd.github+json' }42 });43 if (res.status !== 200) {44 console.error(res);45 throw new Error('Unable to fetch MAINTAINERS file');46 }47 content = Buffer.from(res.data.content, 'base64').toString();48 if (content == null || typeof content !== 'string') {49 throw new Error('Unable to retrieve MAINTAINERS file');50 }5152 const maintainers = new Set(content.split('\n'));53 if (maintainers.has(actor)) {54 console.log(`🟢 ${actor} is a maintainer`);55 return true;56 }57 console.log(`🔴 ${actor} is NOT a maintainer`);58 return null;
Findings
✓ No findings reported for this file.