Skip to content

Commit d15abdf

Browse files
authored
readme: basic docs (#7)
1 parent fa58917 commit d15abdf

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

README.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,76 @@
11
# atlas-deploy-action
2-
A GitHub Action to deploy schema migrations with Atlas
2+
3+
A GitHub Action to deploy versioned migrations with [Atlas](https://atlasgo.io).
4+
5+
## Supported Workflows
6+
7+
- Local - the migration directory is checked in to the repository.
8+
- Cloud - the migration directory is [connected to Atlas Cloud](https://atlasgo.io/cloud/directories).
9+
Runs are reported to your Atlas Cloud account.
10+
11+
## Examples
12+
13+
### Local Workflow
14+
15+
```yaml
16+
name: Deploy Database Migrations
17+
on:
18+
push:
19+
branches:
20+
- master
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
- name: Deploy Atlas Migrations
27+
uses: ariga/atlas-deploy-action@v0
28+
with:
29+
url: ${{ secrets.DATABASE_URL }}
30+
dir: path/to/migrations
31+
```
32+
33+
### Cloud Workflow
34+
35+
```yaml
36+
name: Deploy Database Migrations
37+
on:
38+
push:
39+
branches:
40+
- master
41+
jobs:
42+
deploy:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
- name: Deploy Atlas Migrations
47+
uses: ariga/atlas-deploy-action@v0
48+
with:
49+
url: ${{ secrets.DATABASE_URL }}
50+
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
51+
cloud-dir: hello # replace with your directory name
52+
```
53+
54+
## Reference
55+
56+
### Inputs
57+
58+
- `url`: URL to target database (should be passed as a secret). (Required)
59+
- `dir`: Local path of the migration directory in the repository. (Optional)
60+
- `cloud-token`: Token for using Atlas Cloud (should be passed as a secret). (Optional)
61+
- `cloud-dir`: Name of the migration directory in the cloud. (Must be set if `cloud-token` is set)
62+
- `cloud-tag`: Tag of the migration version in the cloud. (Optional)
63+
64+
Note: Either `dir` or `cloud-dir` must be set. If both are provided, an error will be thrown.
65+
66+
### Outputs
67+
68+
- `error`: Error message if any.
69+
- `current`: Current migration version.
70+
- `target`: Target migration version.
71+
- `pending_count`: Number of pending migrations.
72+
- `applied_count`: Number of applied migrations.
73+
74+
## License
75+
76+
This project is licensed under the [Apache License, Version 2.0](LICENSE).

action.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,29 @@ inputs:
77
url:
88
description: 'URL to target database (should be passed as a secret).'
99
required: true
10+
dir:
11+
description: 'Local path of the migration directory in the repository'
12+
required: false
1013
cloud-token:
1114
description: 'Token for using Atlas Cloud (should be passed as a secret).'
1215
required: false
1316
cloud-dir:
1417
description: 'Name of the migration directory in the cloud'
18+
required: false
19+
cloud-tag:
20+
description: 'Optional. Tag of a migration version in the cloud'
21+
required: false
22+
outputs:
23+
error:
24+
description: 'Error message if any'
25+
current:
26+
description: 'Current migration version'
27+
target:
28+
description: 'Target migration version'
29+
pending_count:
30+
description: 'Number of pending migrations'
31+
applied_count:
32+
description: 'Number of applied migrations'
1533
runs:
1634
using: 'docker'
1735
image: 'docker://arigaio/atlas-deploy-action:latest'

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func Load(act *githubactions.Action) (*Input, error) {
100100
return nil, fmt.Errorf("cloud-token is required when cloud-dir is set")
101101
}
102102
i.Cloud.URL = act.GetInput("cloud-url")
103+
i.Cloud.Tag = act.GetInput("cloud-tag")
103104
return i, nil
104105
}
105106

main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,14 @@ func TestLoad(t *testing.T) {
113113
"INPUT_URL": "sqlite://file.db",
114114
"INPUT_CLOUD-DIR": "dir",
115115
"INPUT_CLOUD-TOKEN": "token",
116+
"INPUT_CLOUD-TAG": "tag",
116117
},
117118
expect: &Input{
118119
URL: "sqlite://file.db",
119120
Cloud: Cloud{
120121
Token: "token",
121122
Dir: "dir",
123+
Tag: "tag",
122124
},
123125
},
124126
},

0 commit comments

Comments
 (0)