Skip to content
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

Allow to Use Custom Git Actor for Bundled JS Output #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: add tutorial section
  • Loading branch information
DavideIadeluca committed Oct 19, 2024
commit f1fd2f035ed47c270d712aa528e7996d57689880
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,72 @@ Your Javascript must be in a `js` folder, similar to how Flarum core and Flarum'

If building typings, we assume that they are built to `js/dist-typings`, as set in the example `tsconfig.json` found on the [flarum-tsconfig](https://github.com/flarum/flarum-tsconfig).

## Setting Up Custom Git Actor for Frontend Workflow

This guide helps you configure a custom Git actor in your extension's frontend workflow, specifically useful if your organization enforces branch protection rules requiring pull requests for changes to the default branch.

### Basic Configuration (Light Version)

To change the actor committing bundled JS in your workflow:

1. Add `git_actor_name` and `git_actor_email` inputs to your workflow file.
2. These values can represent either a real GitHub user or a fictional one.
3. If using a real user, it's recommended to use the GitHub-provided email for privacy-enabled accounts.

Example:

```yaml
name: ACME Foobar JS

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
with:
enable_prettier: true
...
git_actor_name: acme-bot
git_actor_email: 12345678+acme-bot@users.noreply.github.com
```

### Advanced Configuration (With Branch Protection Rules)

If you also want to enforce branch protection and allow a custom actor to bypass pull requests:

1. Create a dedicated CI GitHub account with admin permissions in your organization.
2. Generate a Personal Access Token for the CI account:

- Go to [GitHub Tokens](https://github.com/settings/tokens/new) and create a new token with repo and workflow scopes.

3. Add the token as a secret in your repository.
4. Use the real CI account's username and email in your workflow.

When setting branch protection rules, make sure not to enable "Do not allow bypassing the above settings" as this would block automated commits from the CI actor.

```yml
name: ACME Foobar JS

on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
with:
enable_prettier: true
..
git_actor_name: ci-bot
git_actor_email: ci-bot@users.noreply.github.com

secrets:
git_actor_token: ${{ secrets.GIT_ACTOR_TOKEN }}
```

### Important Notes

- Avoid the "Do not allow bypassing the above settings" option when setting up branch protection, or your CI actor won’t be able to commit the bundled JS.
- Make sure other rules or permissions don't block the CI account from making automated commits.

## Only Build on Master

If you only want to run the workflow when commits are pushed to the `master` branch, change `on: push` to the following:
Expand Down