Skip to content

Commit 3ef880b

Browse files
[DIT-11523] Add support for new and legacy Ditto text using CLI v5.x
2 parents 7e39422 + 17e8c7a commit 3ef880b

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ The Ditto github action creates a PR with the most recent Ditto text updates.
88

99
## Inputs
1010

11-
| Name | Required | Description |
12-
| --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
13-
| ditto-api-key | yes | [Generated Ditto API key](https://developer.dittowords.com/api-reference#creating-an-api-key) |
14-
| 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`). |
15-
| 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`) |
11+
| Name | Required | Description |
12+
| ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
13+
| ditto-api-key | yes | [Generated Ditto API key](https://developer.dittowords.com/api-reference#creating-an-api-key) |
14+
| 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`). |
15+
| 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`) |
16+
| 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. |
1617

1718
## Example Workflow
1819

@@ -24,7 +25,7 @@ jobs:
2425
runs-on: ubuntu-latest
2526
steps:
2627
- name: Pull Ditto text and create a PR
27-
uses: dittowords/ditto-github-action@v0.2.0
28+
uses: dittowords/ditto-github-action@v1.0.0
2829
with:
2930
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
3031
```
@@ -39,20 +40,45 @@ jobs:
3940
runs-on: ubuntu-latest
4041
steps:
4142
- name: Pull Ditto text for Web app and create a PR
42-
uses: dittowords/ditto-github-action@v0.2.0
43+
uses: dittowords/ditto-github-action@v1.0.0
4344
with:
4445
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
4546
ditto-dir: "./web/ditto"
4647
pr-title-prefix: "Web Ditto text update"
4748
4849
- name: Pull Ditto text for iOS app and create a PR
49-
uses: dittowords/ditto-github-action@v0.2.0
50+
uses: dittowords/ditto-github-action@v1.0.0
5051
with:
5152
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
5253
ditto-dir: "./ios/ditto"
5354
pr-title-prefix: "iOS App Ditto text update"
5455
```
5556

57+
### If you have both new and legacy Ditto content in your application
58+
59+
```
60+
name: Update Ditto Text
61+
on: workflow_dispatch
62+
jobs:
63+
UpdateWebDittoText:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Pull Ditto text and create a PR
67+
uses: dittowords/[email protected]
68+
with:
69+
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
70+
ditto-dir: "./new/ditto"
71+
pr-title-prefix: "New Ditto text update"
72+
73+
- name: Pull legacy Ditto text and create a PR
74+
uses: dittowords/[email protected]
75+
with:
76+
ditto-api-key: ${{ secrets.DITTO_API_KEY }}
77+
ditto-dir: "./legacy/ditto"
78+
pr-title-prefix: "Legacy Ditto text update"
79+
pull-from-legacy: "true"
80+
```
81+
5682
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.
5783

5884
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.

action.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ inputs:
1212
description: "String to prefix the pull request title with."
1313
required: false
1414
default: "Ditto text update"
15+
pull-from-legacy:
16+
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."
17+
required: false
18+
default: false
1519
runs:
1620
using: "composite"
1721
steps:
@@ -23,7 +27,7 @@ runs:
2327
uses: actions/setup-node@v1
2428
with:
2529
node-version: 16
26-
- run: npm install --global @dittowords/cli@4.5.2
30+
- run: npm install --global @dittowords/cli^5.0.0
2731
shell: bash
2832
- uses: actions/checkout@v3
2933
with:
@@ -33,7 +37,12 @@ runs:
3337
DITTO_API_KEY: ${{ inputs.ditto-api-key }}
3438
shell: bash
3539
run: |
36-
cd ${{ inputs.ditto-dir }}/.. && npx ditto-cli pull -m githubActionRequest:true
40+
cd ${{ inputs.ditto-dir }}/..
41+
if [ "${{ inputs.pull-from-legacy }}" = "true" ]; then
42+
npx ditto-cli pull --legacy -m githubActionRequest:true
43+
else
44+
npx ditto-cli pull -m githubActionRequest:true
45+
fi
3746
- name: Create Pull Request
3847
uses: peter-evans/create-pull-request@v4
3948
with:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ditto-github-action",
3-
"version": "0.3.1",
3+
"version": "1.0.0",
44
"description": "The Ditto github action creates a PR with the most recent Ditto text updates.",
55
"main": "stats.js",
66
"scripts": {

0 commit comments

Comments
 (0)