@orange-soft/strapi-deployment-trigger 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,7 +38,7 @@ export default () => ({
38
38
  });
39
39
  ```
40
40
 
41
- ### 2. Configure via Admin UI (Recommended)
41
+ ### 2. Configure via Admin UI
42
42
 
43
43
  1. Go to **Plugins > Deployment Trigger > Settings** in your Strapi admin
44
44
  2. Enter your GitHub repository URL (e.g., `https://github.com/owner/repo`)
@@ -46,15 +46,7 @@ export default () => ({
46
46
  4. Enter the branch name to trigger (e.g., `main` or `master`)
47
47
  5. Enter your GitHub Personal Access Token
48
48
 
49
- ### 3. Alternative: Environment Variable for Token
50
-
51
- You can set the GitHub token via environment variable instead of the UI:
52
-
53
- ```bash
54
- GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_xxxxxxxxxxxx
55
- ```
56
-
57
- The plugin will use the database-stored token first, falling back to the environment variable.
49
+ All settings including the token are stored securely in the Strapi database.
58
50
 
59
51
  ## GitHub Token Setup
60
52
 
@@ -180,9 +180,8 @@ const service = ({ strapi }) => ({
180
180
  async getSettings() {
181
181
  const store = strapi.store({ type: "plugin", name: PLUGIN_ID });
182
182
  const dbSettings = await store.get({ key: STORE_KEY });
183
- const envToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
184
183
  if (dbSettings && dbSettings.repoUrl) {
185
- const token2 = dbSettings.githubToken || envToken;
184
+ const token2 = dbSettings.githubToken;
186
185
  return {
187
186
  ...dbSettings,
188
187
  githubToken: void 0,
@@ -191,17 +190,7 @@ const service = ({ strapi }) => ({
191
190
  maskedToken: this.maskToken(token2)
192
191
  };
193
192
  }
194
- const pluginConfig = strapi.config.get(`plugin::${PLUGIN_ID}`) || {};
195
- if (pluginConfig.githubOwner && pluginConfig.githubRepo) {
196
- return {
197
- repoUrl: `https://github.com/${pluginConfig.githubOwner}/${pluginConfig.githubRepo}`,
198
- workflow: pluginConfig.workflow || DEFAULT_SETTINGS.workflow,
199
- branch: pluginConfig.branch || DEFAULT_SETTINGS.branch,
200
- hasToken: !!envToken,
201
- maskedToken: this.maskToken(envToken)
202
- };
203
- }
204
- const token = dbSettings?.githubToken || envToken;
193
+ const token = dbSettings?.githubToken;
205
194
  return {
206
195
  ...DEFAULT_SETTINGS,
207
196
  ...dbSettings,
@@ -224,16 +213,13 @@ const service = ({ strapi }) => ({
224
213
  return {
225
214
  ...settingsToSave,
226
215
  githubToken: void 0,
227
- hasToken: !!settingsToSave.githubToken || !!process.env.GITHUB_PERSONAL_ACCESS_TOKEN
216
+ hasToken: !!settingsToSave.githubToken
228
217
  };
229
218
  },
230
219
  async getToken() {
231
220
  const store = strapi.store({ type: "plugin", name: PLUGIN_ID });
232
221
  const dbSettings = await store.get({ key: STORE_KEY });
233
- if (dbSettings?.githubToken) {
234
- return dbSettings.githubToken;
235
- }
236
- return process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
222
+ return dbSettings?.githubToken || null;
237
223
  },
238
224
  async isConfigured() {
239
225
  const settings = await this.getSettings();
@@ -179,9 +179,8 @@ const service = ({ strapi }) => ({
179
179
  async getSettings() {
180
180
  const store = strapi.store({ type: "plugin", name: PLUGIN_ID });
181
181
  const dbSettings = await store.get({ key: STORE_KEY });
182
- const envToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
183
182
  if (dbSettings && dbSettings.repoUrl) {
184
- const token2 = dbSettings.githubToken || envToken;
183
+ const token2 = dbSettings.githubToken;
185
184
  return {
186
185
  ...dbSettings,
187
186
  githubToken: void 0,
@@ -190,17 +189,7 @@ const service = ({ strapi }) => ({
190
189
  maskedToken: this.maskToken(token2)
191
190
  };
192
191
  }
193
- const pluginConfig = strapi.config.get(`plugin::${PLUGIN_ID}`) || {};
194
- if (pluginConfig.githubOwner && pluginConfig.githubRepo) {
195
- return {
196
- repoUrl: `https://github.com/${pluginConfig.githubOwner}/${pluginConfig.githubRepo}`,
197
- workflow: pluginConfig.workflow || DEFAULT_SETTINGS.workflow,
198
- branch: pluginConfig.branch || DEFAULT_SETTINGS.branch,
199
- hasToken: !!envToken,
200
- maskedToken: this.maskToken(envToken)
201
- };
202
- }
203
- const token = dbSettings?.githubToken || envToken;
192
+ const token = dbSettings?.githubToken;
204
193
  return {
205
194
  ...DEFAULT_SETTINGS,
206
195
  ...dbSettings,
@@ -223,16 +212,13 @@ const service = ({ strapi }) => ({
223
212
  return {
224
213
  ...settingsToSave,
225
214
  githubToken: void 0,
226
- hasToken: !!settingsToSave.githubToken || !!process.env.GITHUB_PERSONAL_ACCESS_TOKEN
215
+ hasToken: !!settingsToSave.githubToken
227
216
  };
228
217
  },
229
218
  async getToken() {
230
219
  const store = strapi.store({ type: "plugin", name: PLUGIN_ID });
231
220
  const dbSettings = await store.get({ key: STORE_KEY });
232
- if (dbSettings?.githubToken) {
233
- return dbSettings.githubToken;
234
- }
235
- return process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
221
+ return dbSettings?.githubToken || null;
236
222
  },
237
223
  async isConfigured() {
238
224
  const settings = await this.getSettings();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orange-soft/strapi-deployment-trigger",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Strapi v5 plugin to trigger GitHub Actions workflow deployments from the admin panel",
5
5
  "license": "MIT",
6
6
  "author": "Justin Moh <moh@os.my>",
@@ -34,13 +34,11 @@ const service = ({ strapi }) => ({
34
34
  },
35
35
 
36
36
  async getSettings() {
37
- // 1. Try database (core store)
38
37
  const store = strapi.store({ type: 'plugin', name: PLUGIN_ID });
39
38
  const dbSettings = await store.get({ key: STORE_KEY });
40
- const envToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
41
39
 
42
40
  if (dbSettings && dbSettings.repoUrl) {
43
- const token = dbSettings.githubToken || envToken;
41
+ const token = dbSettings.githubToken;
44
42
  return {
45
43
  ...dbSettings,
46
44
  githubToken: undefined, // Never expose full token
@@ -49,20 +47,8 @@ const service = ({ strapi }) => ({
49
47
  };
50
48
  }
51
49
 
52
- // 2. Fallback to plugin config (convert old format if needed)
53
- const pluginConfig = strapi.config.get(`plugin::${PLUGIN_ID}`) || {};
54
- if (pluginConfig.githubOwner && pluginConfig.githubRepo) {
55
- return {
56
- repoUrl: `https://github.com/${pluginConfig.githubOwner}/${pluginConfig.githubRepo}`,
57
- workflow: pluginConfig.workflow || DEFAULT_SETTINGS.workflow,
58
- branch: pluginConfig.branch || DEFAULT_SETTINGS.branch,
59
- hasToken: !!envToken,
60
- maskedToken: this.maskToken(envToken),
61
- };
62
- }
63
-
64
- // 3. Return defaults merged with any partial DB settings
65
- const token = dbSettings?.githubToken || envToken;
50
+ // Return defaults merged with any partial DB settings
51
+ const token = dbSettings?.githubToken;
66
52
  return {
67
53
  ...DEFAULT_SETTINGS,
68
54
  ...dbSettings,
@@ -92,20 +78,14 @@ const service = ({ strapi }) => ({
92
78
  return {
93
79
  ...settingsToSave,
94
80
  githubToken: undefined,
95
- hasToken: !!settingsToSave.githubToken || !!process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
81
+ hasToken: !!settingsToSave.githubToken,
96
82
  };
97
83
  },
98
84
 
99
85
  async getToken() {
100
- // Priority: DB token > Environment variable
101
86
  const store = strapi.store({ type: 'plugin', name: PLUGIN_ID });
102
87
  const dbSettings = await store.get({ key: STORE_KEY });
103
-
104
- if (dbSettings?.githubToken) {
105
- return dbSettings.githubToken;
106
- }
107
-
108
- return process.env.GITHUB_PERSONAL_ACCESS_TOKEN;
88
+ return dbSettings?.githubToken || null;
109
89
  },
110
90
 
111
91
  async isConfigured() {