Skip to content

Commit 13f4225

Browse files
committed
feat(): v0.0.1
0 parents  commit 13f4225

File tree

5 files changed

+123
-0
lines changed

5 files changed

+123
-0
lines changed

Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM postgres:alpine
2+
3+
COPY clone.sh /clone.sh
4+
RUN chmod +x /clone.sh
5+
ENTRYPOINT ["/clone.sh"]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 Monoid Dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# PostgreSQL GitHub Action
2+
3+
This [GitHub Action](https://github.com/features/actions) will clone a PostgreSQL database from source to destination.
4+
5+
# Usage
6+
7+
See [action.yml](action.yml)
8+
9+
Basic:
10+
```yaml
11+
steps:
12+
- uses: MonoidDev/clone-postgresql-action@v1
13+
with:
14+
from-host: 'host'
15+
from-port: 'port'
16+
from-username: 'username'
17+
from-password: 'password'
18+
from-database: 'db-name'
19+
to-host: 'host'
20+
to-port: 'port'
21+
to-username: 'username'
22+
to-password: 'password'
23+
to-database: 'db-name'
24+
```
25+
26+
# License
27+
28+
The scripts and documentation in this project are released under the [MIT License](LICENSE)

action.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Clone PostgreSQL'
2+
description: 'Clone a PostgreSQL database'
3+
author: 'Monoid Dev'
4+
branding:
5+
icon: 'database'
6+
color: 'blue'
7+
inputs:
8+
from-host:
9+
description: 'Hostname of Source PostgreSQL'
10+
required: true
11+
default: 'localhost'
12+
from-port:
13+
description: 'Port of Source PostgreSQL'
14+
required: true
15+
default: '5432'
16+
from-username:
17+
description: 'Username of Source PostgreSQL'
18+
required: true
19+
default: 'username'
20+
from-password:
21+
description: 'Password of Source PostgreSQL'
22+
required: true
23+
default: 'password'
24+
from-database:
25+
description: 'Database Name of Source PostgreSQL'
26+
required: true
27+
default: 'db-name'
28+
to-host:
29+
description: 'Hostname of Remote PostgreSQL'
30+
required: true
31+
default: 'localhost'
32+
to-port:
33+
description: 'Port of Remote PostgreSQL'
34+
required: true
35+
default: '5432'
36+
to-username:
37+
description: 'Username of Remote PostgreSQL'
38+
required: true
39+
default: 'username'
40+
to-password:
41+
description: 'Password of Remote PostgreSQL'
42+
required: true
43+
default: 'password'
44+
to-database:
45+
description: 'Database Name of Remote PostgreSQL'
46+
required: true
47+
default: 'db-name'
48+
runs:
49+
using: 'docker'
50+
image: 'Dockerfile'
51+
args:
52+
- ${{ inputs.from-host }}
53+
- ${{ inputs.from-port }}
54+
- ${{ inputs.from-username }}
55+
- ${{ inputs.from-password }}
56+
- ${{ inputs.from-database }}
57+
- ${{ inputs.to-host }}
58+
- ${{ inputs.to-port }}
59+
- ${{ inputs.to-username }}
60+
- ${{ inputs.to-password }}
61+
- ${{ inputs.to-database }}
62+

clone.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
# dump the database in custom-format archive
4+
PGPASSWORD=$4 pg_dump -Fc -U $3 -h $1 -p $2 $5 > db.dump
5+
6+
# restore the database
7+
PGPASSWORD=$9 pg_restore -U $8 -h $6 -p $7 -d ${10} db.dump --clean

0 commit comments

Comments
 (0)