Skip to content

Commit 5cee355

Browse files
authored
Make "Subtree Split" using GitHub Actions (#1179)
1 parent 918d765 commit 5cee355

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

.github/actions/subtree/action.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This worflow is based on GitHub documentation:
2+
# https://docs.github.com/en/get-started/using-git/splitting-a-subfolder-out-into-a-new-repository
3+
# This workflow uses https://github.com/newren/git-filter-repo tool.
4+
5+
name: "Subtree Split"
6+
description: "Take the content of one repository and split it into many smaller ones"
7+
inputs:
8+
directory:
9+
description: "Directory to split"
10+
required: true
11+
repository:
12+
description: "Repository to push to (in the same organization)"
13+
required: true
14+
outputs:
15+
changes:
16+
description: "Is there any changes in the directory?"
17+
value: ${{ steps.changes.outputs.directory }}
18+
files:
19+
description: "List of files changed in the directory"
20+
value: ${{ steps.changes.outputs.files }}
21+
runs:
22+
using: "composite"
23+
steps:
24+
- name: Detect changes
25+
uses: dorny/paths-filter@v2
26+
id: changes
27+
with:
28+
list-files: shell
29+
filters: |
30+
directory:
31+
- "${{ inputs.directory }}/**"
32+
- name: Subtree
33+
if: steps.changes.outputs.directory == 'true'
34+
shell: bash
35+
run: |
36+
wget -P /usr/local/bin https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo
37+
chmod +x /usr/local/bin/git-filter-repo
38+
git filter-repo --debug --subdirectory-filter "${{ inputs.directory }}/"
39+
- name: Push subtree
40+
if: steps.changes.outputs.directory == 'true'
41+
shell: bash
42+
run: |
43+
git remote add subtree "https://github.com/geocoder-php/${{ inputs.repository }}.git"
44+
git push --force --set-upstream subtree master

.github/workflows/subtree.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# This GitHub Action will push code for each provider/component to its own repository.
2+
# This is useful to have a better overview of the code and to have a better control over the releases.
3+
# The subtree is pushed to a repository named `geocoder-php/{provider}-provider`.
4+
# Previously, this process used https://www.subtreesplit.com/ service.
5+
#
6+
# This worflow is based on GitHub documentation: https://docs.github.com/en/get-started/using-git/splitting-a-subfolder-out-into-a-new-repository
7+
# This workflow uses https://github.com/newren/git-filter-repo tool.
8+
#
9+
# This workflow needs a GitHub token with Contents and Workflows read & write scopes.
10+
11+
name: Subtree Split
12+
13+
on:
14+
push:
15+
branches: [ "master" ]
16+
17+
jobs:
18+
subtree-common:
19+
name: Subtree for Common
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v3
23+
with:
24+
token: ${{ secrets.SUBTREE_GITHUB_TOKEN }}
25+
fetch-depth: 0
26+
- name: Subtree Split
27+
uses: ./.github/actions/subtree
28+
with:
29+
directory: src/Common
30+
repository: php-common
31+
32+
subtree-http:
33+
name: Subtree for Http
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v3
37+
with:
38+
token: ${{ secrets.SUBTREE_GITHUB_TOKEN }}
39+
fetch-depth: 0
40+
- name: Subtree Split
41+
uses: ./.github/actions/subtree
42+
with:
43+
directory: src/Http
44+
repository: php-common-http
45+
46+
subtree-plugin:
47+
name: Subtree for Plugin
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
with:
52+
token: ${{ secrets.SUBTREE_GITHUB_TOKEN }}
53+
fetch-depth: 0
54+
- name: Subtree Split
55+
uses: ./.github/actions/subtree
56+
with:
57+
directory: src/Plugin
58+
repository: plugin
59+
60+
subtree-provider:
61+
name: Subtree for provider ${{ matrix.provider }}
62+
runs-on: ubuntu-latest
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
provider:
67+
- AlgoliaPlaces
68+
- ArcGISOnline
69+
- AzureMaps
70+
- BingMaps
71+
- Cache
72+
- Chain
73+
- FreeGeoIp
74+
- GeoIP2
75+
# - GeoIPs
76+
- GeoPlugin
77+
- GeocodeEarth
78+
- Geonames
79+
- GoogleMaps
80+
- GoogleMapsPlaces
81+
- GraphHopper
82+
- Here
83+
- HostIp
84+
- IP2Location
85+
# - IP2LocationBinary
86+
- IpInfo
87+
- IpInfoDb
88+
- Ipstack
89+
- LocationIQ
90+
- MapQuest
91+
- Mapbox
92+
# - Mapzen
93+
- MaxMind
94+
- MaxMindBinary
95+
- Nominatim
96+
- OpenCage
97+
- OpenRouteService
98+
- Pelias
99+
- Photon
100+
- PickPoint
101+
- TomTom
102+
- Yandex
103+
steps:
104+
- uses: actions/checkout@v3
105+
with:
106+
token: ${{ secrets.SUBTREE_GITHUB_TOKEN }}
107+
fetch-depth: 0
108+
- name: Subtree Split
109+
uses: ./.github/actions/subtree
110+
with:
111+
directory: "src/Provider/${{ matrix.provider }}"
112+
repository: ${{ matrix.provider }}-provider

0 commit comments

Comments
 (0)