{"id":14109228,"url":"https://github.com/imjohnbo/ok-to-test","last_synced_at":"2025-08-01T08:31:11.554Z","repository":{"id":39058199,"uuid":"266229164","full_name":"imjohnbo/ok-to-test","owner":"imjohnbo","description":"Example workflow configuration showing how to use GitHub Actions secrets in pull requests from forks 🍴🔑","archived":false,"fork":false,"pushed_at":"2023-03-17T16:25:39.000Z","size":51,"stargazers_count":74,"open_issues_count":0,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-01T04:54:19.936Z","etag":null,"topics":["forks","github-actions","prow","pull-requests","secrets","workflow"],"latest_commit_sha":null,"homepage":"https://github.com/imjohnbo/ok-to-test","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imjohnbo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-05-22T23:48:55.000Z","updated_at":"2024-09-13T07:59:44.000Z","dependencies_parsed_at":"2024-01-28T23:45:46.148Z","dependency_job_id":null,"html_url":"https://github.com/imjohnbo/ok-to-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjohnbo%2Fok-to-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjohnbo%2Fok-to-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjohnbo%2Fok-to-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imjohnbo%2Fok-to-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imjohnbo","download_url":"https://codeload.github.com/imjohnbo/ok-to-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228351707,"owners_count":17906540,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["forks","github-actions","prow","pull-requests","secrets","workflow"],"created_at":"2024-08-14T10:02:10.100Z","updated_at":"2024-12-05T18:30:55.365Z","avatar_url":"https://github.com/imjohnbo.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# Ok To Test\n\n\u003e _Example workflow configuration_ showing how to use GitHub Actions secrets in pull requests from forks 🍴🔑\n\n## Summary\n\nAn [`Ok To Test`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/ok-to-test.yml) workflow is configured so that when someone with write access to this repository comments `ok-to-test sha=\u003chead-sha\u003e` on a pull request from a fork, a \"privileged\" [`Integration tests`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/integration.yml) workflow needing [secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#about-encrypted-secrets) is triggered. In parallel, a \"non-privileged\" [`Unit tests`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/unit.yml) workflow not needing secrets is triggered on any pull request.\n\n## About\n\nGitHub Actions purposely limits the [secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) available to pull requests from forks for security reasons:\n\n- [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token) is read-only\n- [Other secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets#using-encrypted-secrets-in-a-workflow) aren't available at all\n\nThough this provides peace of mind, many projects depend on the fork pull request model. If you've configured a GitHub Actions test workflow to trigger on pull requests, and those tests require secrets, the secrets aren't available and the workflow fails.\n\nNo longer with this workaround, which shows an example [Prow](https://prow.k8s.io/command-help)-like `/ok-to-test sha=\u003chead-sha\u003e` slash command configuration! 🥳\n\nThis project is not affiliated with GitHub.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://user-images.githubusercontent.com/2993937/101568108-0b2d4980-39a0-11eb-9e87-d838ae934097.png\" width=\"600\" /\u003e\n\u003c/p\u003e\n\n## Setup\n\nThis is a [template repository](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template#about-repository-templates) with three example workflows. Start by [creating a new repository](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template#creating-a-repository-from-a-template) (\"Use this template\"). Then, consider for your use case:\n\n1. [Which type of token](#authentication) you'll use to emit the `repository_dispatch` event in [`Ok To Test`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/ok-to-test.yml). Set the secrets in your repository accordingly, e.g. [I used a GitHub App](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/ok-to-test.yml#L20-L21) and had to save secrets called `APP_ID` and `PRIVATE_KEY`. Remember: if you also choose GitHub App authentication (preferred), you must create _and install_ it on the repo(s) in which this configuration will run. See [Creating A GitHub App](#creating-a-github-app) for a basic overview of how to do this.\n1. Which workflow(s) need [secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#about-encrypted-secrets). In this example, it's [`Integration tests`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/integration.yml), and I would need to fill in my tests [here](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/integration.yml#L36).\n1. Which workflow(s) do not need [secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets#about-encrypted-secrets). In this example, it's [`Unit tests`](https://github.com/imjohnbo/ok-to-test/blob/master/.github/workflows/unit.yml). These types of workflows can simply trigger on pull request.\n1. The Permissions required for your `GITHUB_TOKEN`. The workflows used to implement `ok-to-test` require the ability to: add reactions to your pull request comments, and update the status of your pull request checks. Currently GitHub Actions' built-in `GITHUB_TOKEN` is [`read`-only by default](https://github.blog/changelog/2023-02-02-github-actions-updating-the-default-github_token-permissions-to-read-only/). The example workflows in this repo explicitly grant the necessary `write` permissions to the jobs that require them. You can read more about this in the [GitHub Docs](https://docs.github.com/en/actions/security-guides/automatic-token-authentication), which also describe how to update the defaults.\n\n## Usage\n\nAs someone with write access, comment `/ok-to-test sha=\u003chead-sha\u003e` on an incoming pull request to set off this [Rube Goldberg machine](https://en.wikipedia.org/wiki/Rube_Goldberg_machine) 😄. The head `sha` is the first seven characters of the most recent commit of the incoming pull request. [For example](https://github.com/imjohnbo/ok-to-test/pull/5#issuecomment-635368312), `/ok-to-test sha=742c71a`.\n\n## Example\n\n1. A fork pull request is opened.\n2. A [unit test workflow](.github/workflows/unit.yml) runs. Secrets are not available to this workflow.\n3. Someone with [write access](https://help.github.com/en/github/getting-started-with-github/access-permissions-on-github) looks over the pull request code. ⚠️ Before proceeding, they should be sure the code isn't doing anything malicious like secret logging. ⚠️\n4. They comment `/ok-to-test sha=\u003chead-sha\u003e` on the pull request.\n5. A `repository_dispatch` API request is sent to this repository. See guidance [below](#authentication) on how to authenticate.\n6. An [integration test workflow](.github/workflows/integration.yml) runs, checking out the merge commit if the head sha hasn't changed since the comment was made. Secrets are available to this workflow! 💫\n7. The pull request status check is updated to reflect the success or failure of the integration test workflow.\n\nNote that this sequence also works for branch based pull requests, as you'd expect!\n\n## Authentication\n\nChoose one of these authentication methods for the `repository_dispatch` helper action, `peter-evans/slash-command-dispatch`, in [`ok-to-test.yml`](.github/workflows/ok-to-test.yml):\n\n- [Personal access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line) with `repo` scope\n- [OAuth \"app\" token](https://developer.github.com/v3/#oauth2-token-sent-in-a-header) with `repo` scope\n- ⭐️ Preferred: [GitHub App installation access token](https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-an-installation) with `contents: write` and `metadata: read` permissions. See [Creating A GitHub App](#creating-a-github-app) for a basic overview of how to do this.\n\nGitHub Apps have distinct identities on GitHub – no seat taken up by a machine account, no potential for leaking your personal credentials, and no rate limit sharing!\n\n### Creating a GitHub App\n\nHere we are using a GitHub App as an authentication entity. Below are some brief instructions on how to setup a GitHub App for this purpose, note that there are other methods of creating a GitHub App such as with a manifest file (e.g. one similar to [`app.yml`](/app.yml)). _(The instructions below are for setting up an app within your user, but you can also do it for your organization.)_\n\n1. Go to `Settings \u003e Developer Settings \u003e GitHub Apps`, and select `New GitHub App`.\n1. Enter a name for your app (this needs to be unique across GitHub), and fill in the required URL fields. You can fill in these URLs with fake values - they do not need to resolve, so you can use:\n    - Homepage URL = `http://example.com`\n1. You can ignore the 'Callback URL' field, and untick `'Webook' \u003e Active`\n1. Under `Repository Permissions`, set:\n    - Contents = 'Read and Write'\n    - Metadata = 'Read-only'\n1. Click 'Create GitHub app'\n1. Click 'Generate Private key' (this will be downloaded to your computer), and take a note of the `App ID` field\n1. Install the GitHub App into your user or organization, by clicking 'Install' under the 'Install App' tab, and choose whether you want to give the app access to all of your user's / org's repositories, or just specific ones\n1. Go to the repository that you want to use `ok-to-test` with, and then `Settings \u003e Secrets and variables \u003e Actions` and create two new secrets:\n    - `APP_ID` with the value for the `App ID` field that you noted earlier\n    - `PRIVATE_KEY`, copying and pasting in the full contents of the Private Key file that you generated and downloaded earlier\n\n## Credits\n\n- [Prow](https://prow.k8s.io/command-help) for the idea for `ok-to-test`\n- A few handy community actions, [`peter-evans/slash-command-dispatch`](https://github.com/peter-evans/slash-command-dispatch), [`tibdex/github-app-token`](https://github.com/tibdex/github-app-token), and [`actions/github-script`](https://github.com/actions/github-script)\n\n## Contributing\n\nPull requests are welcome!\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjohnbo%2Fok-to-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimjohnbo%2Fok-to-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimjohnbo%2Fok-to-test/lists"}