5

I'm trying to organize my workflow artifacts (on a self-hosted runner) using a structure similar to this:

c:\github\artifacts\{org}\{repo}\{runid}

Different organizations in our enterprise COULD have a repository with the same name, so I wanted to be able to organize by organization name.

I have this so far:

c:\github\artifacts\{org}\{${{ github.event.repository.name }}\${{ github.run_id }}\

How can I determine the organization name?

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
bperniciaro
  • 901
  • 2
  • 12
  • 30
  • 3
    Try **github.event.repository.full_name** which gives you both the org and repository name or **github.event.repository.owner.name** which is just the org. – John Hanley Jan 13 '22 at 21:54

1 Answers1

10

You can get that from github context. The repo name and the repository organization can be found with:

  • ${{ github.repository }} (repo name)
  • ${{ github.repository_owner }} (repo organization)

If you don't know what are the values and which env variables are available to runner, you can just run env in a step to print it out, like so:

name: Print environment variables

on:
  workflow_dispatch:

jobs:
  debug:
    runs-on: ubuntu-latest

    steps:
      - name: Print
        run: env | sort
L_Cleo
  • 1,073
  • 1
  • 10
  • 26
frennky
  • 12,581
  • 10
  • 47
  • 63