Skip to content

Add optional environment variables to get workflow from another repo #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

marksmithsonuk
Copy link
Contributor

Description

This PR adds the option to set 'custom' environment variables for the GitHub repository and owner.

Motivation

We have a lot of repositories in our organisation, so to avoid having to add the exporter workflow to each of them and maintain them, I was looking at ways to run a single workflow and have all the other repos 'report' to it (via a repository_dispatch API call). In order for this to work though, we need to override the GITHUB_REPOSITORY environment variable, which isn't possible currently in a GitHub Actions workflow. So we needed to be able to set a different environment variable which could be ignored if the workflow was just running in the same repository. I've also added a new environment variable for GitHub owner - although we don't need this ourselves it might be useful for someone.

Example

      - name: Export GHA to New Relic
        id: exporter
        uses: newrelic-experimental/gha-new-relic-exporter@latest
        env:
          GHA_TOKEN: <TOKEN>
          NEW_RELIC_LICENSE_KEY: <KEY>
          GHA_RUN_ID: ${{ github.event.client_payload.workflow_run_id }}
          GHA_RUN_NAME: ${{ github.event.client_payload.workflow_name }}
          GHA_REPOSITORY_OWNER: ${{ github.repository_owner }}
          GHA_REPOSITORY: ${{ github.event.client_payload.repository }}

@CLAassistant
Copy link

CLAassistant commented Oct 4, 2024

CLA assistant check
All committers have signed the CLA.

@dpacheconr dpacheconr merged commit e1c165b into newrelic-experimental:main Oct 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants