Skip to content

Commit 4489d67

Browse files
committed
ci: rename the secret to GH_PUSH_TOKEN
1 parent cf252ae commit 4489d67

File tree

6 files changed

+164
-100
lines changed

6 files changed

+164
-100
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: 'Create Pull Request'
2+
description: 'Creates a pull request for syncing with web-shim-codegen'
3+
4+
inputs:
5+
owner:
6+
description: 'Repository owner'
7+
required: true
8+
repo:
9+
description: 'Repository name'
10+
required: true
11+
package_version:
12+
description: 'Package version to include in PR title'
13+
required: true
14+
base:
15+
description: 'Base branch for the PR'
16+
required: false
17+
default: 'main'
18+
head:
19+
description: 'Head branch for the PR'
20+
required: false
21+
default: 'cd_update'
22+
github_token:
23+
description: 'GitHub token for authentication'
24+
required: true
25+
26+
runs:
27+
using: 'composite'
28+
steps:
29+
- name: Create Pull Request
30+
uses: actions/github-script@v7
31+
continue-on-error: true
32+
with:
33+
script: |
34+
await github.rest.pulls.create({
35+
owner: '${{ inputs.owner }}',
36+
repo: '${{ inputs.repo }}',
37+
title: 'ci: sync with web-shim-codegen v' + '${{ inputs.package_version }}',
38+
body: 'This update was generated by the GitHub CD action.',
39+
base: '${{ inputs.base }}',
40+
head: '${{ inputs.head }}'
41+
});
42+
env:
43+
GITHUB_TOKEN: ${{ inputs.github_token }}

.github/workflows/cd.yml

Lines changed: 65 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -13,181 +13,149 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: '[Setup] Checkout Repository'
16-
uses: actions/checkout@v3
17-
with:
18-
persist-credentials: false
19-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
16+
uses: actions/checkout@v6
17+
2018
- name: '[Setup] Node'
21-
uses: actions/setup-node@v3
19+
uses: actions/setup-node@v6
2220
with:
2321
node-version: 18
22+
2423
- name: '[Setup] Bootstrap Dependencies'
25-
run: bash scripts/bootstrap-dependencies
24+
run: npm ci
25+
2626
- name: '[Setup] Git'
2727
run: |
2828
git config --global user.email "noreply@onesignal.com"
2929
git config --global user.name "OneSignal"
30-
env:
31-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
30+
3231
- name: 'Get current web-shim-codegen version'
3332
run: |
3433
echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
34+
3535
- name: '[Setup] Build'
3636
run: npm run build
37+
3738
- name: '[onesignal-ngx] Checkout'
38-
uses: actions/checkout@v3
39+
uses: actions/checkout@v6
3940
with:
40-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
41+
token: ${{ secrets.GH_PUSH_TOKEN }}
4142
repository: OneSignal/onesignal-ngx
4243
fetch-depth: 0
4344
path: __clone/onesignal-ngx
45+
4446
- name: '[onesignal-ngx] Patch'
4547
run: |
46-
bash scripts/clean-repo.sh __clone/onesignal-ngx package-lock.json
47-
tar zxvvf dist/onesignal-ngx.tgz -C __clone/
48-
cd __clone/onesignal-ngx
49-
git add -A
50-
if git commit -m "feat: sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}"; then
51-
echo "onesignal-ngx repository has been updated"
52-
else
53-
echo "onesignal-ngx repository has NOT been updated, no changes to commit"
54-
fi
48+
bash scripts/patch-repo.sh dist/onesignal-ngx.tgz __clone/onesignal-ngx onesignal-ngx
49+
env:
50+
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
51+
5552
- name: '[onesignal-ngx] Push'
5653
uses: ad-m/github-push-action@v0.6.0
5754
with:
5855
repository: OneSignal/onesignal-ngx
5956
directory: __clone/onesignal-ngx
6057
force: true
6158
branch: cd_update
62-
github_token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
59+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
60+
6361
- name: '[onesignal-ngx] Submit PR'
64-
uses: octokit/request-action@v2.x
65-
continue-on-error: true
62+
uses: ./.github/actions/create-pr
6663
with:
67-
route: POST /repos/{owner}/{repo}/pulls
68-
owner: OneSignal
69-
repo: onesignal-ngx
70-
base: main
71-
head: cd_update
72-
title: 'sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}'
73-
body: 'This update was generated by the GitHub CD action.'
74-
env:
75-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
64+
owner: 'OneSignal'
65+
repo: 'onesignal-ngx'
66+
package_version: ${{ env.PACKAGE_VERSION }}
67+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
68+
7669
- name: '[react-onesignal] Checkout'
7770
uses: actions/checkout@v3
7871
with:
79-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
72+
token: ${{ secrets.GH_PUSH_TOKEN }}
8073
repository: OneSignal/react-onesignal
8174
fetch-depth: 0
8275
submodules: true
8376
path: __clone/react
77+
8478
- name: '[react-onesignal] Patch'
8579
run: |
86-
bash scripts/clean-repo.sh __clone/react
87-
tar zxvvf dist/react.tgz -C __clone/
88-
cd __clone/react
89-
git add -A
90-
if git commit -m "feat: sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}"; then
91-
echo "react-onesignal repository has been updated"
92-
else
93-
echo "react-onesignal repository has NOT been updated, no changes to commit"
94-
fi
80+
bash scripts/patch-repo.sh dist/react.tgz __clone/react react-onesignal
81+
env:
82+
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
83+
9584
- name: '[react-onesignal] Push'
9685
uses: ad-m/github-push-action@v0.6.0
9786
with:
9887
repository: OneSignal/react-onesignal
9988
directory: __clone/react
10089
force: true
10190
branch: cd_update
102-
github_token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
91+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
92+
10393
- name: '[react-onesignal] Submit PR'
104-
uses: octokit/request-action@v2.x
105-
continue-on-error: true
94+
uses: ./.github/actions/create-pr
10695
with:
107-
route: POST /repos/{owner}/{repo}/pulls
108-
owner: OneSignal
109-
repo: react-onesignal
110-
base: main
111-
head: cd_update
112-
title: 'sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}'
113-
body: 'This update was generated by the GitHub CD action.'
114-
env:
115-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
96+
owner: 'OneSignal'
97+
repo: 'react-onesignal'
98+
package_version: ${{ env.PACKAGE_VERSION }}
99+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
100+
116101
- name: '[onesignal-vue] Checkout'
117102
uses: actions/checkout@v3
118103
with:
119-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
104+
token: ${{ secrets.GH_PUSH_TOKEN }}
120105
repository: OneSignal/onesignal-vue
121106
fetch-depth: 0
122107
path: __clone/vue/v2
108+
123109
- name: '[onesignal-vue] Patch'
124110
run: |
125-
bash scripts/clean-repo.sh __clone/vue/v2
126-
tar zxvvf dist/vue/v2.tgz -C __clone/
127-
cd __clone/vue/v2
128-
git add -A
129-
if git commit -m "feat: sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}"; then
130-
echo "onesignal-vue repository has been updated"
131-
else
132-
echo "onesignal-vue repository has NOT been updated, no changes to commit"
133-
fi
111+
bash scripts/patch-repo.sh dist/vue/v2.tgz __clone/vue/v2 onesignal-vue
112+
env:
113+
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
114+
134115
- name: '[onesignal-vue] Push'
135116
uses: ad-m/github-push-action@v0.6.0
136117
with:
137118
repository: OneSignal/onesignal-vue
138119
directory: __clone/vue/v2
139120
force: true
140121
branch: cd_update
141-
github_token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
122+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
123+
142124
- name: '[onesignal-vue] Submit PR'
143-
uses: octokit/request-action@v2.x
144-
continue-on-error: true
125+
uses: ./.github/actions/create-pr
145126
with:
146-
route: POST /repos/{owner}/{repo}/pulls
147-
owner: OneSignal
148-
repo: onesignal-vue
149-
base: main
150-
head: cd_update
151-
title: 'sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}'
152-
body: 'This update was generated by the GitHub CD action.'
153-
env:
154-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
127+
owner: 'OneSignal'
128+
repo: 'onesignal-vue'
129+
package_version: ${{ env.PACKAGE_VERSION }}
130+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
131+
155132
- name: '[onesignal-vue3] Checkout'
156133
uses: actions/checkout@v3
157134
with:
158-
token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
135+
token: ${{ secrets.GH_PUSH_TOKEN }}
159136
repository: OneSignal/onesignal-vue3
160137
fetch-depth: 0
161138
path: __clone/vue/v3
139+
162140
- name: '[onesignal-vue3] Patch'
163141
run: |
164-
bash scripts/clean-repo.sh __clone/vue/v3
165-
tar zxvvf dist/vue/v3.tgz -C __clone/
166-
cd __clone/vue/v3
167-
git add -A
168-
if git commit -m "feat: sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}"; then
169-
echo "onesignal-vue3 repository has been updated"
170-
else
171-
echo "onesignal-vue3 repository has NOT been updated, no changes to commit"
172-
fi
142+
bash scripts/patch-repo.sh dist/vue/v3.tgz __clone/vue/v3 onesignal-vue3
143+
env:
144+
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
145+
173146
- name: '[onesignal-vue3] Push'
174147
uses: ad-m/github-push-action@v0.6.0
175148
with:
176149
repository: OneSignal/onesignal-vue3
177150
directory: __clone/vue/v3
178151
force: true
179152
branch: cd_update
180-
github_token: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
153+
github_token: ${{ secrets.GH_PUSH_TOKEN }}
154+
181155
- name: '[onesignal-vue3] Submit PR'
182-
uses: octokit/request-action@v2.x
183-
continue-on-error: true
156+
uses: ./.github/actions/create-pr
184157
with:
185-
route: POST /repos/{owner}/{repo}/pulls
186-
owner: OneSignal
187-
repo: onesignal-vue3
188-
base: main
189-
head: cd_update
190-
title: 'sync with web-shim-codegen v${{ env.PACKAGE_VERSION }}'
191-
body: 'This update was generated by the GitHub CD action.'
192-
env:
193-
GITHUB_TOKEN: ${{ secrets.GH_WEB_SHIM_PUSH_TOKEN }}
158+
owner: 'OneSignal'
159+
repo: 'onesignal-vue3'
160+
package_version: ${{ env.PACKAGE_VERSION }}
161+
github_token: ${{ secrets.GH_PUSH_TOKEN }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web-shim-codegen",
3-
"version": "3.0.6",
3+
"version": "3.0.7",
44
"description": "Used to build Web SDK libraries for various web frameworks",
55
"main": "index.js",
66
"scripts": {

scripts/patch-repo.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Usage: patch-repo.sh <tar-file> <target-directory> <repo-name>
5+
# Example: patch-repo.sh dist/react.tgz __clone/react react-onesignal
6+
# Requires PACKAGE_VERSION environment variable to be set
7+
8+
if [ $# -lt 3 ]; then
9+
echo "Usage: $0 <tar-file> <target-directory> <repo-name>"
10+
exit 1
11+
fi
12+
13+
TAR_FILE="$1"
14+
TARGET_DIR="$2"
15+
REPO_NAME="$3"
16+
VERSION="${PACKAGE_VERSION:-unknown}"
17+
18+
if [ ! -f "$TAR_FILE" ]; then
19+
echo "Error: Tar file $TAR_FILE does not exist"
20+
exit 1
21+
fi
22+
23+
if [ ! -d "$TARGET_DIR" ]; then
24+
echo "Error: Target directory $TARGET_DIR does not exist"
25+
exit 1
26+
fi
27+
28+
# Extract tar archive
29+
tar zxvvf "$TAR_FILE" -C "$(dirname "$TARGET_DIR")"
30+
31+
# Add all changes and commit
32+
cd "$TARGET_DIR"
33+
git add -A
34+
if git commit -m "chore: sync with web-shim-codegen v$VERSION"; then
35+
echo "$REPO_NAME repository has been updated"
36+
else
37+
echo "$REPO_NAME repository has NOT been updated, no changes to commit"
38+
fi
39+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Checks if the PR title follows semantic commit message conventions
2+
name: Lint PR
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
pull_request:
9+
types: [opened, edited, synchronize]
10+
11+
jobs:
12+
call:
13+
uses: OneSignal/sdk-actions/.github/workflows/lint-pr-title.yml@main
14+
secrets: inherit

src/static/react/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)