Skip to content

Commit e14a1e1

Browse files
committed
Feat: Add move and replace transformations
1 parent 095d67b commit e14a1e1

File tree

7 files changed

+194
-100
lines changed

7 files changed

+194
-100
lines changed

dist/index.js

Lines changed: 45 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/advanced-usage.md

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22

33
## What this action does
44

5-
This action manages 2 workflows out of the box (push, pr) and essentially does two things:
5+
This action manages 2 workflows out of the box (**push**, **pr**) and essentially has three steps:
66

77
1. **Detect** which workflow to run depending on the context:
88

99
- _Push to SoT_ => **push**
10-
- _PR opened/changed on destination_ => **pr**
10+
- _PR opened/updated on destination_ => **pr**
1111

1212
> If the destination branch doesn't exist on **push**, it will add the flags `--force --init-history`
1313
1414
2. **Generate** a configuration for each workflow
1515

16+
3. **Run** Copybara
17+
1618
## What you can do
1719

1820
### Force specific workflows
1921

20-
The following will ensure the **push** workflow is ran using the auto-generated configuration file.
22+
_The following will let you override step 1 but let Copybara Action perform step 2 and 3._
23+
24+
It will ensure the **push** workflow is ran using the auto-generated configuration file.
2125

2226
```yaml
2327
on:
@@ -32,22 +36,25 @@ jobs:
3236

3337
- uses: olivr/[email protected]
3438
with:
39+
ssh_key: ${{ secrets.SSH_KEY }}
3540
sot_repo: your/repo
3641
destination_repo: other/repo
3742
workflow: push
38-
ssh_key: ${{ secrets.SSH_KEY }}
3943
```
4044
4145
### Custom Copybara configuration
4246
43-
The following will use your configuration instead of the automatically generated one.
47+
_The following will let Copybara Action perform step 1 and 3 but let you override step 2._
48+
49+
It will use your configuration instead of the automatically generated one.
4450
You can get inspiration from the [generated config](#generated-config) to get started.
4551
4652
> This example is still making use of the workflow detection so `my.own.copy.bara.sky` must contain a **push** and a **pr** workflow
4753

4854
```yaml
4955
on:
5056
push:
57+
pull_request_target:
5158
jobs:
5259
move-code:
5360
runs-on: ubuntu-latest
@@ -58,15 +65,18 @@ jobs:
5865
5966
- uses: olivr/[email protected]
6067
with:
68+
access_token: ${{ secrets.GH_TOKEN }}
69+
ssh_key: ${{ secrets.SSH_KEY }}
6170
sot_repo: your/repo
6271
destination_repo: other/repo
6372
custom_config: my.own.copy.bara.sky
64-
ssh_key: ${{ secrets.SSH_KEY }}
6573
```
6674

6775
### Completely custom
6876

69-
The following doesn't make use of any of our helpers for detecting the workflow and generating the configuration.
77+
_The following will let you override step 1, 2 and let you customize how Copybara Action will perform step 3._
78+
79+
It doesn't make use of any of our helpers for detecting the workflow and generating the configuration.
7080
It is even using a custom Copybara docker image!
7181

7282
```yaml
@@ -82,16 +92,18 @@ jobs:
8292
8393
- uses: olivr/[email protected]
8494
with:
85-
workflow: export
95+
access_token: ${{ secrets.GH_TOKEN }}
96+
ssh_key: ${{ secrets.SSH_KEY }}
97+
workflow: create
8698
custom_config: my.own.copy.bara.sky
8799
copybara_image: sharelatex/copybara
88-
ssh_key: ${{ secrets.SSH_KEY }}
100+
copybara_options: --force --init-history
89101
```
90102

91103
### SoT not on GitHub
92104

93-
This action's auto-generated configuration was made for a use case with two GitHub repos. However
94-
If your SoT is not on GitHub, you can still use this action on your destination using a custom config and forcing a specific workflow:
105+
This action's auto-generated configuration was made for a use case with two GitHub repos. However, if your SoT is not on GitHub, this action is still helpful.
106+
Use it on your destination with a custom config and a specific workflow:
95107

96108
```yaml
97109
on:
@@ -102,21 +114,20 @@ jobs:
102114
steps:
103115
- uses: olivr/[email protected]
104116
with:
117+
ssh_key: ${{ secrets.SSH_KEY }}
105118
workflow: pr
106119
custom_config: my.own.copy.bara.sky
107-
ssh_key: ${{ secrets.SSH_KEY }}
108120
```
109121

110122
### [More options](inputs.md)
111123

112124
## Generated config
113125

114-
So you don't have to start your config from scratch, let's download your current generated one.
115-
116-
When you enable debug mode, this action will create an artifact containing your copy.bara.sky configuration.
126+
So you don't have to start your custom config from scratch, you can download the generated one.
117127

118128
1. In your repo(s), add the secret `ACTIONS_STEP_DEBUG` and set it to `true`
119-
2. Run the action workflow (most likely create a commit in SoT and a PR in destination)
120-
3. Check out the artifacts for this workflow run
129+
2. Run the action workflow (ie. push a commit to SoT and create a PR in destination)
130+
3. Check out the artifacts for your action workflow runs
121131

132+
It will look like this:
122133
![artifact](images/artifact.png)

0 commit comments

Comments
 (0)