Skip to content

Commit f70ce37

Browse files
authored
Merge pull request #1 from benrowe/feature/github-action
Feature/GitHub action
2 parents e5edc6e + fb290f1 commit f70ce37

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ FROM python:alpine3.9
22

33
RUN pip install mysql-to-sqlite3 && mkdir -p /output && touch /output/export.sqlite3
44

5+
COPY entrypoint.sh /entrypoint.sh
6+
57
VOLUME [ "/output" ]
68

7-
CMD ["mysql2sqlite", "-f /output/export.sqlite3"]
9+
ENTRYPOINT [ "/entrypoint.sh" ]
810

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
# MySQL to SQLite3 (Docker)
1+
# MySQL to SQLite3 (Docker + Github action)
22

33
Implements [MySQL to SQLite3][link-sql] as a docker utility
44

5-
## How to use
5+
## How to use as docker
66

77
```
8-
docker run --rm -v ${PWD}:/output benrowe/mysql-to-sqlite3 mysql2sqlite -f /output/export.sqlite3 -d database_name -u username -h host.docker.internal -p password
8+
docker run --rm -v ${PWD}:/output benrowe/mysql-to-sqlite3 database_name username host.docker.internal password path/to/file
9+
```
10+
11+
## How to use as github action
12+
13+
The github action runs this command inside the docker file, so the host will need to point to the host machien
14+
15+
```
16+
- name: Convert to SQLite
17+
uses: benrowe/mysql-to-sqlite3-docker@v1
18+
with:
19+
output: /path/to/file
20+
database: database
21+
host: localhost
22+
username: root
23+
password: password
924
```
1025

1126
[link-sql]:https://github.com/techouse/mysql-to-sqlite3

action.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: MySQL to SQLite3 Converter
2+
description: Connect to mysql and convert to sqlite3 file
3+
4+
5+
inputs:
6+
output:
7+
description: output file
8+
required: true
9+
database:
10+
description: mysql database name
11+
required: true
12+
host:
13+
description: mysql host address
14+
required: true
15+
username:
16+
description: mysql username
17+
required: true
18+
password:
19+
description: mysql password
20+
required: true
21+
22+
outputs:
23+
file:
24+
description: The file that is generated
25+
26+
runs:
27+
using: docker
28+
image: Dockerfile
29+
args:
30+
- ${{ inputs.host }}
31+
- ${{ inputs.database }}
32+
- ${{ inputs.username }}
33+
- ${{ inputs.password }}
34+
- ${{ inputs.output }}
35+
post-entrypoint: gh-output.sh
36+
37+
branding:
38+
icon: "filter"
39+
color: "blue"
40+

entrypoint.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
HOST=$1
4+
DATABASE=$2
5+
USERNAME=$3
6+
PASSWORD=$4
7+
OUTPUT=$5
8+
9+
mysql2sqlite -f /output/export/ -d $DATABASE -u $USERNAME -h $HOST -p $PASSWORD -f $OUTPUT

gh-output.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
echo "::file::/path/to/dir"

0 commit comments

Comments
 (0)