Actions Metadata

August 5, 2022 · View on GitHub

All repo and event metadata for use in Actions workflows

license test semantic

Why

GitHub Actions already contains plenty of context for use within Actions workflows.

However, it's very limited, and does not include the entirety of the repository metadata.

Usage

jobs:
  job:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - id: metadata
        uses: ahmadnassri/action-metadata@v2

      # simple usage example
      - run: |
        echo ${{ steps.metadata.outputs.repository_full_name }}
        echo ${{ steps.metadata.outputs.owner_login }}
        echo ${{ steps.metadata.outputs.template_repository_name }}

      # legacy (v1) usage example: use the full JSON object
      - run: |
        echo ${{ fromJSON(steps.metadata.outputs.repository_json).full_name }}
        echo ${{ fromJSON(steps.metadata.outputs.repository_json).owner.login }}
        echo ${{ fromJSON(steps.metadata.outputs.repository_json).template_repository.name }}

      # advanced usage example:
      - run: |
        echo ${{ steps.metadata.outputs.repository_json }}" | jq '.full_name, .owner.login, .template_repository.name'

Outputs

This action will output the following properties:

propertyexample
repository_json{ ... } full JSON object of the current repository
repository_id368563995
repository_nameaction-metadata
repository_full_nameahmadnassri/action-metadata
repository_privatefalse
repository_html_urlhttps://github.com/ahmadnassri/action-metadata
repository_descriptionget all the repository metadata for use in Actions
repository_forkfalse
repository_created_at2021-05-18T14:38:41Z
repository_updated_at2021-11-13T06:48:56Z
repository_pushed_at2022-08-03T14:36:17Z
repository_git_urlgit://github.com/ahmadnassri/action-metadata.git
repository_ssh_urlgit@github.com:ahmadnassri/action-metadata.git
repository_clone_urlhttps://github.com/ahmadnassri/action-metadata.git
repository_svn_urlhttps://github.com/ahmadnassri/action-metadata
repository_homepagehttps://ahmadnassri.com/projects/
repository_size24
repository_stargazers_count1
repository_watchers_count1
repository_languageShell
repository_has_issuestrue
repository_has_projectsfalse
repository_has_downloadsfalse
repository_has_wikifalse
repository_has_pagesfalse
repository_forks_count0
repository_archivedfalse
repository_disabledfalse
repository_open_issues_count5
repository_allow_forkingtrue
repository_is_templatefalse
repository_web_commit_signoff_requiredfalse
repository_visibilitypublic
repository_default_branchmaster
repository_allow_squash_mergetrue
repository_allow_merge_commitfalse
repository_allow_rebase_mergetrue
repository_allow_auto_mergetrue
repository_delete_branch_on_mergetrue
repository_allow_update_branchtrue
repository_use_squash_pr_title_as_defaultfalse
repository_network_count0
repository_subscribers_count1
license_keymit
license_nameMIT License
license_spdx_idMIT
owner_id183195
owner_loginahmadnassri
owner_avatar_urlhttps://avatars.githubusercontent.com/u/183195?v=4
owner_html_urlhttps://github.com/ahmadnassri
owner_typeUser
template_repository_id342988151
template_repository_nametemplate-action-composite
template_repository_full_nameahmadnassri/template-action-composite
template_repository_html_urlhttps://github.com/ahmadnassri/template-action-composite

Author: Ahmad Nassri • Twitter: @AhmadNassri