Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ The Ditto github action creates a PR with the most recent Ditto text updates.

## Inputs

| Name | Required | Description |
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ditto-api-key | yes | [Generated Ditto API key](https://developer.dittowords.com/api-reference#creating-an-api-key) |
| ditto-dir | no | `ditto` directory location. Only required if the `ditto` directory is not located at the root of your repository. Must include 'ditto' (e.g. `./src/ditto`). |
| pr-title-prefix | no | String to prefix the pull request title with (e.g. "Web App Ditto Updates" would result in a PR titled: `Web App Ditto Updates YYYY-MM-DDT`) |
| Name | Required | Description |
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ditto-api-key | yes | [Generated Ditto API key](https://developer.dittowords.com/api-reference#creating-an-api-key) |
| ditto-dir | no | `ditto` directory location. Only required if the `ditto` directory is not located at the root of your repository. Must include 'ditto' (e.g. `./src/ditto`). |
| pr-title-prefix | no | String to prefix the pull request title with (e.g. "Web App Ditto Updates" would result in a PR titled: `Web App Ditto Updates YYYY-MM-DDT`) |
| pull-from-legacy | no | By default, the action will pull from the latest version of Ditto. Set this to true to pull from legacy Ditto projects based on a legacy config file. |

## Example Workflow

Expand All @@ -24,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Pull Ditto text and create a PR
uses: dittowords/ditto-github-action@v0.2.0
uses: dittowords/ditto-github-action@v1.0.0
with:
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
```
Expand All @@ -39,20 +40,45 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Pull Ditto text for Web app and create a PR
uses: dittowords/ditto-github-action@v0.2.0
uses: dittowords/ditto-github-action@v1.0.0
with:
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
ditto-dir: "./web/ditto"
pr-title-prefix: "Web Ditto text update"

- name: Pull Ditto text for iOS app and create a PR
uses: dittowords/ditto-github-action@v0.2.0
uses: dittowords/ditto-github-action@v1.0.0
with:
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
ditto-dir: "./ios/ditto"
pr-title-prefix: "iOS App Ditto text update"
```

### If you have both new and legacy Ditto content in your application

```
name: Update Ditto Text
on: workflow_dispatch
jobs:
UpdateWebDittoText:
runs-on: ubuntu-latest
steps:
- name: Pull Ditto text and create a PR
uses: dittowords/[email protected]
with:
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
ditto-dir: "./new/ditto"
pr-title-prefix: "New Ditto text update"

- name: Pull legacy Ditto text and create a PR
uses: dittowords/[email protected]
with:
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
ditto-dir: "./legacy/ditto"
pr-title-prefix: "Legacy Ditto text update"
pull-from-legacy: "true"
```

This example workflow allows you to [manually start the workflow](https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow) resulting in the creation of a PR.

It is recommended to pass the `ditto-api-key` via a [GitHub secret](https://docs.github.com/en/actions/security-guides/encrypted-secrets) to prevent your API key from getting exposed to the public.
13 changes: 11 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: "String to prefix the pull request title with."
required: false
default: "Ditto text update"
pull-from-legacy:
description: "By default, will pull from the latest version of Ditto. Set this to true to pull from legacy Ditto projects based on a legacy config file."
required: false
default: false
runs:
using: "composite"
steps:
Expand All @@ -23,7 +27,7 @@ runs:
uses: actions/setup-node@v1
with:
node-version: 16
- run: npm install --global @dittowords/cli@4.5.2
- run: npm install --global @dittowords/cli^5.0.0
shell: bash
- uses: actions/checkout@v3
with:
Expand All @@ -33,7 +37,12 @@ runs:
DITTO_API_KEY: ${{ inputs.ditto-api-key }}
shell: bash
run: |
cd ${{ inputs.ditto-dir }}/.. && npx ditto-cli pull -m githubActionRequest:true
cd ${{ inputs.ditto-dir }}/..
if [ "${{ inputs.pull-from-legacy }}" = "true" ]; then
npx ditto-cli pull --legacy -m githubActionRequest:true
else
npx ditto-cli pull -m githubActionRequest:true
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ditto-github-action",
"version": "0.3.1",
"version": "1.0.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change (and points to a new major version of the CLI), so I have bumped the version all the way up.

"description": "The Ditto github action creates a PR with the most recent Ditto text updates.",
"main": "stats.js",
"scripts": {
Expand Down