Skip to content

Commit a3ef0f0

Browse files
committed
ci: use matrix for deployment
1 parent 4489d67 commit a3ef0f0

File tree

1 file changed

+56
-107
lines changed

1 file changed

+56
-107
lines changed

.github/workflows/cd.yml

Lines changed: 56 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ env:
99
TERM: xterm-256color
1010

1111
jobs:
12-
dist:
12+
setup:
1313
runs-on: ubuntu-latest
14+
outputs:
15+
package_version: ${{ steps.version.outputs.version }}
1416
steps:
1517
- name: '[Setup] Checkout Repository'
1618
uses: actions/checkout@v6
@@ -23,139 +25,86 @@ jobs:
2325
- name: '[Setup] Bootstrap Dependencies'
2426
run: npm ci
2527

26-
- name: '[Setup] Git'
27-
run: |
28-
git config --global user.email "noreply@onesignal.com"
29-
git config --global user.name "OneSignal"
30-
3128
- name: 'Get current web-shim-codegen version'
29+
id: version
3230
run: |
33-
echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
31+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
3432
3533
- name: '[Setup] Build'
3634
run: npm run build
3735

38-
- name: '[onesignal-ngx] Checkout'
39-
uses: actions/checkout@v6
36+
- name: 'Upload dist artifacts'
37+
uses: actions/upload-artifact@v4
4038
with:
41-
token: ${{ secrets.GH_PUSH_TOKEN }}
42-
repository: OneSignal/onesignal-ngx
43-
fetch-depth: 0
44-
path: __clone/onesignal-ngx
39+
name: dist
40+
path: dist/
41+
retention-days: 1
4542

46-
- name: '[onesignal-ngx] Patch'
47-
run: |
48-
bash scripts/patch-repo.sh dist/onesignal-ngx.tgz __clone/onesignal-ngx onesignal-ngx
49-
env:
50-
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
51-
52-
- name: '[onesignal-ngx] Push'
53-
uses: ad-m/github-push-action@v0.6.0
54-
with:
55-
repository: OneSignal/onesignal-ngx
56-
directory: __clone/onesignal-ngx
57-
force: true
58-
branch: cd_update
59-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
60-
61-
- name: '[onesignal-ngx] Submit PR'
62-
uses: ./.github/actions/create-pr
63-
with:
64-
owner: 'OneSignal'
65-
repo: 'onesignal-ngx'
66-
package_version: ${{ env.PACKAGE_VERSION }}
67-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
68-
69-
- name: '[react-onesignal] Checkout'
70-
uses: actions/checkout@v3
71-
with:
72-
token: ${{ secrets.GH_PUSH_TOKEN }}
73-
repository: OneSignal/react-onesignal
74-
fetch-depth: 0
75-
submodules: true
76-
path: __clone/react
77-
78-
- name: '[react-onesignal] Patch'
79-
run: |
80-
bash scripts/patch-repo.sh dist/react.tgz __clone/react react-onesignal
81-
env:
82-
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
83-
84-
- name: '[react-onesignal] Push'
85-
uses: ad-m/github-push-action@v0.6.0
86-
with:
87-
repository: OneSignal/react-onesignal
88-
directory: __clone/react
89-
force: true
90-
branch: cd_update
91-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
92-
93-
- name: '[react-onesignal] Submit PR'
94-
uses: ./.github/actions/create-pr
95-
with:
96-
owner: 'OneSignal'
97-
repo: 'react-onesignal'
98-
package_version: ${{ env.PACKAGE_VERSION }}
99-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
100-
101-
- name: '[onesignal-vue] Checkout'
102-
uses: actions/checkout@v3
103-
with:
104-
token: ${{ secrets.GH_PUSH_TOKEN }}
105-
repository: OneSignal/onesignal-vue
106-
fetch-depth: 0
107-
path: __clone/vue/v2
43+
sync-repo:
44+
needs: setup
45+
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
include:
49+
- repo: onesignal-ngx
50+
dist_path: dist/onesignal-ngx.tgz
51+
clone_path: __clone/onesignal-ngx
52+
has_submodules: false
53+
- repo: react-onesignal
54+
dist_path: dist/react.tgz
55+
clone_path: __clone/react
56+
has_submodules: true
57+
- repo: onesignal-vue
58+
dist_path: dist/vue/v2.tgz
59+
clone_path: __clone/vue/v2
60+
has_submodules: false
61+
- repo: onesignal-vue3
62+
dist_path: dist/vue/v3.tgz
63+
clone_path: __clone/vue/v3
64+
has_submodules: false
65+
steps:
66+
- name: '[Setup] Checkout Repository'
67+
uses: actions/checkout@v6
10868

109-
- name: '[onesignal-vue] Patch'
69+
- name: '[Setup] Git'
11070
run: |
111-
bash scripts/patch-repo.sh dist/vue/v2.tgz __clone/vue/v2 onesignal-vue
112-
env:
113-
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
114-
115-
- name: '[onesignal-vue] Push'
116-
uses: ad-m/github-push-action@v0.6.0
117-
with:
118-
repository: OneSignal/onesignal-vue
119-
directory: __clone/vue/v2
120-
force: true
121-
branch: cd_update
122-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
71+
git config --global user.email "noreply@onesignal.com"
72+
git config --global user.name "OneSignal"
12373
124-
- name: '[onesignal-vue] Submit PR'
125-
uses: ./.github/actions/create-pr
74+
- name: 'Download dist artifacts'
75+
uses: actions/download-artifact@v4
12676
with:
127-
owner: 'OneSignal'
128-
repo: 'onesignal-vue'
129-
package_version: ${{ env.PACKAGE_VERSION }}
130-
github_token: ${{ secrets.GH_PUSH_TOKEN }}
77+
name: dist
78+
path: dist/
13179

132-
- name: '[onesignal-vue3] Checkout'
133-
uses: actions/checkout@v3
80+
- name: '[${{ matrix.repo }}] Checkout'
81+
uses: actions/checkout@v6
13482
with:
13583
token: ${{ secrets.GH_PUSH_TOKEN }}
136-
repository: OneSignal/onesignal-vue3
84+
repository: OneSignal/${{ matrix.repo }}
13785
fetch-depth: 0
138-
path: __clone/vue/v3
86+
submodules: ${{ matrix.has_submodules }}
87+
path: ${{ matrix.clone_path }}
13988

140-
- name: '[onesignal-vue3] Patch'
89+
- name: '[${{ matrix.repo }}] Patch'
14190
run: |
142-
bash scripts/patch-repo.sh dist/vue/v3.tgz __clone/vue/v3 onesignal-vue3
91+
bash scripts/patch-repo.sh ${{ matrix.dist_path }} ${{ matrix.clone_path }} ${{ matrix.repo }}
14392
env:
144-
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
93+
PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }}
14594

146-
- name: '[onesignal-vue3] Push'
95+
- name: '[${{ matrix.repo }}] Push'
14796
uses: ad-m/github-push-action@v0.6.0
14897
with:
149-
repository: OneSignal/onesignal-vue3
150-
directory: __clone/vue/v3
98+
repository: OneSignal/${{ matrix.repo }}
99+
directory: ${{ matrix.clone_path }}
151100
force: true
152101
branch: cd_update
153102
github_token: ${{ secrets.GH_PUSH_TOKEN }}
154103

155-
- name: '[onesignal-vue3] Submit PR'
104+
- name: '[${{ matrix.repo }}] Submit PR'
156105
uses: ./.github/actions/create-pr
157106
with:
158107
owner: 'OneSignal'
159-
repo: 'onesignal-vue3'
160-
package_version: ${{ env.PACKAGE_VERSION }}
108+
repo: ${{ matrix.repo }}
109+
package_version: ${{ needs.setup.outputs.package_version }}
161110
github_token: ${{ secrets.GH_PUSH_TOKEN }}

0 commit comments

Comments
 (0)