Skip to content

Commit 400e601

Browse files
Improve Workflow (#1033)
Co-authored-by: dr5hn <6929121+dr5hn@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 5b12d92 commit 400e601

38 files changed

Lines changed: 132404 additions & 65681 deletions

.github/workflows/export.yml

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,31 @@ jobs:
3737
php-version: ${{ matrix.php-version }}
3838
extensions: intl #optional
3939
coverage: none
40-
ini-values: "post_max_size=256M" #optional
40+
ini-values: "post_max_size=256M, memory_limit=512M" #optional
4141

4242
- name: Use Node.js ${{ matrix.node-version }}
4343
uses: actions/setup-node@v4
4444
with:
4545
node-version: ${{ matrix.node-version }}
46+
cache: 'npm'
47+
cache-dependency-path: nmig/package-lock.json
48+
49+
- name: Cache Composer dependencies
50+
uses: actions/cache@v4
51+
with:
52+
path: bin/vendor
53+
key: ${{ runner.os }}-composer-${{ hashFiles('bin/composer.lock') }}
54+
restore-keys: ${{ runner.os }}-composer-
4655

4756
- name: Start MySQL service
4857
run: |
4958
sudo systemctl start mysql.service
5059
mysql -V
60+
# Wait for MySQL to be ready
61+
while ! mysqladmin ping -h"127.0.0.1" --silent; do
62+
echo "Waiting for MySQL..."
63+
sleep 1
64+
done
5165
5266
- name: Start PostgreSQL service
5367
run: |
@@ -67,9 +81,8 @@ jobs:
6781
- name: Install MongoDB Database Tools
6882
run: |
6983
# Download MongoDB Database Tools directly
70-
wget https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.7.3.deb
84+
wget -q https://fastdl.mongodb.org/tools/db/mongodb-database-tools-ubuntu2204-x86_64-100.7.3.deb
7185
sudo dpkg -i mongodb-database-tools-ubuntu2204-x86_64-100.7.3.deb
72-
7386
rm -rf mongodb-database-tools-ubuntu2204-x86_64-100.7.3.deb
7487
7588
# Verify installation
@@ -86,8 +99,7 @@ jobs:
8699
87100
- name: Setup MySQL DB
88101
run: |
89-
ls -R
90-
mysql -uroot -proot -e "CREATE DATABASE world;"
102+
mysql -uroot -proot -e "CREATE DATABASE world CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
91103
mysql -uroot -proot -e "SHOW DATABASES;"
92104
mysql -uroot -proot --default-character-set=utf8mb4 world < sql/world.sql
93105
@@ -98,6 +110,7 @@ jobs:
98110
npm install
99111
npm run build
100112
npm start
113+
cd ..
101114
102115
- name: Setup MySQLtoSQLite
103116
run: |
@@ -138,16 +151,18 @@ jobs:
138151

139152
- name: Export MySQL SQL
140153
run: |
141-
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world regions > sql/regions.sql
142-
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world subregions > sql/subregions.sql
143-
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world countries > sql/countries.sql
144-
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world states > sql/states.sql
145-
mysqldump -uroot -proot --add-drop-table --disable-keys --set-charset --skip-add-locks world cities > sql/cities.sql
154+
mkdir -p sql
155+
mysqldump -uroot -proot --single-transaction --add-drop-table --disable-keys --set-charset --skip-add-locks world regions > sql/regions.sql
156+
mysqldump -uroot -proot --single-transaction --add-drop-table --disable-keys --set-charset --skip-add-locks world subregions > sql/subregions.sql
157+
mysqldump -uroot -proot --single-transaction --add-drop-table --disable-keys --set-charset --skip-add-locks world countries > sql/countries.sql
158+
mysqldump -uroot -proot --single-transaction --add-drop-table --disable-keys --set-charset --skip-add-locks world states > sql/states.sql
159+
mysqldump -uroot -proot --single-transaction --add-drop-table --disable-keys --set-charset --skip-add-locks world cities > sql/cities.sql
146160
147161
- name: Export PostgreSQL SQL
148162
env:
149163
PGPASSWORD: postgres
150164
run: |
165+
mkdir -p psql
151166
pg_dump --dbname=postgresql://postgres:postgres@localhost/world -Fp --inserts --clean --if-exists -t regions > psql/regions.sql
152167
pg_dump --dbname=postgresql://postgres:postgres@localhost/world -Fp --inserts --clean --if-exists -t subregions > psql/subregions.sql
153168
pg_dump --dbname=postgresql://postgres:postgres@localhost/world -Fp --inserts --clean --if-exists -t countries > psql/countries.sql
@@ -157,6 +172,10 @@ jobs:
157172
158173
- name: Export SQLite
159174
run: |
175+
# Clean up any existing SQLite files first
176+
rm -rf sqlite/
177+
mkdir -p sqlite
178+
160179
mysql2sqlite -d world -t regions --mysql-password root -u root -f sqlite/regions.sqlite3
161180
mysql2sqlite -d world -t subregions --mysql-password root -u root -f sqlite/subregions.sqlite3
162181
mysql2sqlite -d world -t countries --mysql-password root -u root -f sqlite/countries.sqlite3
@@ -207,14 +226,48 @@ jobs:
207226
sed -i "s/Last Updated On : .*$/Last Updated On : $current_date/" README.md
208227
209228
- name: Create Pull Request
210-
uses: peter-evans/create-pull-request@v6
229+
uses: peter-evans/create-pull-request@v7
211230
with:
212-
commit-message: Add exported JSON, CSV, XML, YAML, MYSQL, PSQL, SQLITE, MONGODB & SQL Server files
231+
commit-message: |
232+
📦 Export database formats - ${{ env.current_date }}
233+
234+
✅ All export formats completed successfully:
235+
- JSON/XML/YAML/CSV: Structured data exports
236+
- MySQL/PostgreSQL: SQL dump exports
237+
- SQLite: Database file exports
238+
- SQL Server/MongoDB: Alternative format exports
239+
240+
📊 Total records: ${{ env.country_count }} countries, ${{ env.state_count }} states, ${{ env.city_count }} cities
213241
committer: Darshan Gada <gadadarshan@gmail.com>
214242
signoff: true
215243
branch: export/Files
216244
delete-branch: true
217-
title: "(chore): Export JSON, CSV, XML, YAML, MYSQL, PSQL, SQLITE, MONGODB & SQL Server files"
245+
title: "🚀 Database Export - ${{ env.current_date }}"
246+
body: |
247+
## 📦 Database Export Success
248+
249+
All export formats have been successfully generated.
250+
251+
### 📊 Data Statistics
252+
- **Regions**: ${{ env.region_count }}
253+
- **Subregions**: ${{ env.subregion_count }}
254+
- **Countries**: ${{ env.country_count }}
255+
- **States**: ${{ env.state_count }}
256+
- **Cities**: ${{ env.city_count }}
257+
258+
### ✅ Generated Formats
259+
- **JSON** - Structured data format
260+
- **XML** - Markup language format
261+
- **YAML** - Human-readable format
262+
- **CSV** - Spreadsheet format
263+
- **MySQL** - Database dumps
264+
- **PostgreSQL** - Database dumps
265+
- **SQLite** - Portable databases
266+
- **SQL Server** - T-SQL scripts
267+
- **MongoDB** - Collections + dump
268+
269+
---
270+
*Generated automatically by GitHub Actions*
218271
labels: |
219272
exports
220273
automated

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Total Countries : 250 <br>
4646
Total States/Regions/Municipalities : 5,038 <br>
4747
Total Cities/Towns/Districts : 151,024 <br>
4848

49-
Last Updated On : 01th Apr 2025
49+
Last Updated On : 28th May 2025
5050

5151
## Next API Database Update
5252

0 commit comments

Comments
 (0)