GitHub Action
The Lunaria GitHub Action comments on pull requests with an overview of how the changes made will affect the localization status generated after merging, including insights on possible issues and how Lunaria works.
Prerequisites
- Node.js -
v20.0.0
or higher. @lunariajs/core
-v0.1.0
or higher.
Set up the Action
Create a new file in your project at .github/workflows/lunaria.yml
with the following content, according to the package manager used:
name: Lunaria
on: # Trigger the workflow every time a pull request is opened or synchronized at the target `main` branch # Using a different branch name? Replace `main` with your branch’s name pull_request_target: types: [opened, synchronize] branches: [main]
# Allow this job to clone the repository and comment on the pull requestpermissions: contents: read pull-requests: write
jobs: lunaria-overview: name: Generate Lunaria Overview runs-on: ubuntu-latest
steps: - name: Checkout uses: actions/checkout@v4 with: # Necessary for Lunaria to work properly # Makes the action clone the entire git history fetch-depth: 0
- name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: npm
- run: npm install
- name: Generate Lunaria Overview uses: yanthomasdev/lunaria-action@v0.1.0
name: Lunaria
on: # Trigger the workflow every time a pull request is opened or synchronized at the target `main` branch # Using a different branch name? Replace `main` with your branch’s name pull_request_target: types: [opened, synchronize] branches: [main]
# Allow this job to clone the repository and comment on the pull requestpermissions: contents: read pull-requests: write
jobs: lunaria-overview: name: Generate Lunaria Overview runs-on: ubuntu-latest
steps: - name: Checkout uses: actions/checkout@v4 with: # Necessary for Lunaria to work properly # Makes the action clone the entire git history fetch-depth: 0
- name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm
- name: Setup PNPM uses: pnpm/action-setup@v3
- run: pnpm install
- name: Generate Lunaria Overview uses: yanthomasdev/lunaria-action@v0.1.0
name: Lunaria
on: # Trigger the workflow every time a pull request is opened or synchronized at the target `main` branch # Using a different branch name? Replace `main` with your branch’s name pull_request_target: types: [opened, synchronize] branches: [main]
# Allow this job to clone the repository and comment on the pull requestpermissions: contents: read pull-requests: write
jobs: lunaria-overview: name: Generate Lunaria Overview runs-on: ubuntu-latest
steps: - name: Checkout uses: actions/checkout@v4 with: # Necessary for Lunaria to work properly # Makes the action clone the entire git history fetch-depth: 0
- name: Setup Node uses: actions/setup-node@v4 with: node-version: 20 cache: yarn
- run: yarn install
- name: Generate Lunaria Overview uses: yanthomasdev/lunaria-action@v0.1.0
If everything was set up properly, the Action will now comment on every new, or updated pull request that has files tracked by Lunaria (those who do not, won’t receive a comment).
Additional step for monorepos
By default, the Action will look for the @lunariajs/core
package within the base directory of your repository.
If you’re using a monorepo and the package is not installed in the root package.json
file, you’ll need to set the working-directory
to the correct path.
This example assumes the @lunariajs/core
package was installed in the docs/package.json
file, meaning working-directory
should be set to docs
:
- name: Generate Lunaria Overview uses: yanthomasdev/lunaria-action@v0.1.0 with: working-directory: docs
Additional steps for private repositories
By default, the Action won’t run on a private repository for a lack of permissions. To fix this, you will need to follow a few additional steps:
-
Create a new personal access token (PAT) on GitHub and add it to your repository’s Action secrets.
-
Add the
token
input to both the Checkout and Lunaria steps of your workflow file at.github/workflows/lunaria.yml
with the corresponding secret name you added earlier:- name: Checkoutuses: actions/checkout@v4with:# Necessary for Lunaria to work properly# Makes the action clone the entire git historyfetch-depth: 0token: ${{ secrets.PAT }}- name: Generate Lunaria Overviewuses: yanthomasdev/lunaria-action@v0.1.0with:token: ${{ secrets.PAT }}
Reference
Inputs
-
token
- Optional: a GitHub personal access token to run the Action with.- name: Generate Lunaria Overviewuses: yanthomasdev/lunaria-action@v0.1.0with:token: ${{ secrets.PAT }} -
working-directory
- Optional: a desired working directory for the Action to be run on. Should be set to the subdirectory where@lunariajs/core
was installed.- name: Generate Lunaria Overviewuses: yanthomasdev/lunaria-action@v0.1.0with:working-directory: docs