Skip to content

πŸ“Š πŸ“‘ Action to generate a report as markdown, html or json with the members, outside collaborators and pending invites.

License

Notifications You must be signed in to change notification settings

ActionsDesk/enterprise-members-report-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Enterprise members report action

Action to generate a report as markdown, html, csv or json with the members, outside collaborators and pending invites.

Description

This action generates a report for an enterprise with the following elements:

  • Members: a report of all users that are members of at least one org in the enterprise
  • Outside collaborators: a compilation of all outside collaborators in all the orgs
  • Pending invites: the list of all pending invites in all the orgs

How to

This actions has the following inputs:

Parameter Description Default Is Required
token A personal access token with permissions on all the orgs of the enterprise None βœ…
enterprise The enterprise where we want to generate the report None βœ…
format Determines how the output parameter will be formatted. Supports: json, markdown, csv and html None βœ…
licenseUsage Enterprise License consumption CSV contents None ❎
licenseUsageChanged Enterprise License consumption CSV last changed date/time None ❎

This action has the following outputs:

Parameter Description
data The data extracted from the license API calls in the format specified. The type of the output is always string

Here you can see a workflow example using this action:

name: Report workflow
on: 
  schedule:
    # every Tuesday at 07:00 UTC
    - cron: '0 7 * * 3'

jobs:
  sendReport:
    runs-on: 'ubuntu-latest'
    steps:
    - name: Generate report
      id: report
      uses: ActionsDesk/enterprise-members-report-action@main
      env:
        # The default GITHUB_TOKEN from actions doesn't work here as it does not have enough permissions
        GITHUB_TOKEN: ${{ secrets.YOUR_SECRET_TOKEN }}
      with:
        enterprise: avocado-corp
        format: 'html'
    # Then use ${{ steps.report.outputs.data }} to store/send the report somewhere
    - run: echo '${{ steps.report.outputs.data }}'

License Consumption Merging

At present it is not possible to use the GitHub API to obtain the type of license a user is consuming. You can download the consumed_licenses.csv file from the enterprise portal, https://docs.github.com/en/billing/managing-your-license-for-github-enterprise/viewing-license-usage-for-github-enterprise, and the action can merge this information into the report. You will need to commit the consumed_licenses.csv to your repository, and update it when you need an up to date report.

You will also need to ensure that the action has the content available for it, add the following step before you generate any reports:

      - name: Export license usage data
        run: | 
          if [[ -f consumed_licenses.csv ]]; then
            echo "LICENSEUSAGE_CSV<<EOF" >> $GITHUB_ENV
            cat consumed_licenses.csv >> $GITHUB_ENV
            echo "EOF" >> $GITHUB_ENV
            echo "LICENSEUSAGE_CSV_CHANGED=$(stat -c'%Y' consumed_licenses.csv | date -Iseconds)" >> $GITHUB_ENV
          fi

Then you can update the report generator with the extra settings:

      - name: Generate CSV report
        id: report_csv
        uses: ActionsDesk/enterprise-members-report-action@latest
        env:
          GITHUB_TOKEN: ${{ secrets.YOUR_SECRET_TOKEN }}
        with:
          enterprise: avocado-corp
          format: 'csv'
          licenseUsage: ${{ env.LICENSEUSAGE_CSV }}
          licenseUsageChanged: ${{ env.LICENSEUSAGE_CSV_CHANGED }}

A new column will be added to the generated report with type of licensed consumed by the user:

Login Emails Orgs Membership Created At License (2021-09-10T16:54:27+01:00)
gwenavocado [email protected] avocado-haas member 2020-09-29T14:07:38Z Visual Studio subscription
fuerteavocado [email protected] avocado-haas,avocado-zutano member 2020-10-14T21:25:58Z Enterprise
toast [email protected] avocado-zutano outside collaborator 2020-10-14T21:25:58Z Enterprise

The variable licenseUsageChanged is optional and if supplied with be included in the License column header as a reference for when the consumed_licenses.csv file was last modified.

Token permissions

The required scopes for this action to run are:

  • admin:enterprise
  • admin:org
  • read:user
  • user:email

About

πŸ“Š πŸ“‘ Action to generate a report as markdown, html or json with the members, outside collaborators and pending invites.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published