@argos-ci/core 1.4.2-alpha.6 → 1.5.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +20 -6
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -122,8 +122,20 @@ const debugTimeEnd = (arg)=>{
122
122
  * deployment sha.
123
123
  */ async function getPullRequestFromHeadSha({ env }, sha) {
124
124
  debug("Fetching pull request number from head sha", sha);
125
- if (!env.GITHUB_REPOSITORY || !env.GITHUB_TOKEN) {
126
- debug("Aborting because GITHUB_REPOSITORY or GITHUB_TOKEN is missing");
125
+ if (!env.GITHUB_REPOSITORY) {
126
+ throw new Error("GITHUB_REPOSITORY is missing");
127
+ }
128
+ if (!env.GITHUB_TOKEN) {
129
+ if (!env.DISABLE_GITHUB_TOKEN_WARNING) {
130
+ console.log(`
131
+ Running argos from a "deployment_status" event requires a GITHUB_TOKEN.
132
+ Please add \`GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}\` as environment variable.
133
+
134
+ Read more at https://argos-ci.com/docs/run-on-preview-deployment
135
+
136
+ To disable this warning, add \`DISABLE_GITHUB_TOKEN_WARNING: true\` as environment variable.
137
+ `.trim());
138
+ }
127
139
  return null;
128
140
  }
129
141
  try {
@@ -145,7 +157,7 @@ const debugTimeEnd = (arg)=>{
145
157
  debug("PR found", firstPr);
146
158
  return firstPr;
147
159
  } catch (error) {
148
- debug("Error while fetching pull request number from head sha", error);
160
+ debug("Error while fetching pull request from head sha", error);
149
161
  return null;
150
162
  }
151
163
  }
@@ -177,7 +189,12 @@ const service$4 = {
177
189
  const payload = readEventPayload({
178
190
  env
179
191
  });
192
+ const sha = process.env.GITHUB_SHA || null;
193
+ if (!sha) {
194
+ throw new Error(`GITHUB_SHA is missing`);
195
+ }
180
196
  const commonConfig = {
197
+ commit: sha,
181
198
  owner: env.GITHUB_REPOSITORY_OWNER || null,
182
199
  repository: getRepository$1({
183
200
  env
@@ -189,13 +206,11 @@ const service$4 = {
189
206
  // If the job is triggered by from a "deployment" or a "deployment_status"
190
207
  if (payload === null || payload === void 0 ? void 0 : payload.deployment) {
191
208
  debug("Deployment event detected");
192
- const { sha } = payload.deployment;
193
209
  const pullRequest = await getPullRequestFromHeadSha({
194
210
  env
195
211
  }, sha);
196
212
  return {
197
213
  ...commonConfig,
198
- commit: payload.deployment.sha,
199
214
  branch: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.head.ref) || payload.deployment.environment || null,
200
215
  prNumber: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.number) || null,
201
216
  prHeadCommit: (pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.head.sha) || null
@@ -203,7 +218,6 @@ const service$4 = {
203
218
  }
204
219
  return {
205
220
  ...commonConfig,
206
- commit: process.env.GITHUB_SHA || null,
207
221
  branch: (payload === null || payload === void 0 ? void 0 : (_payload_pull_request = payload.pull_request) === null || _payload_pull_request === void 0 ? void 0 : _payload_pull_request.head.ref) || getBranch({
208
222
  env
209
223
  }) || null,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/core",
3
3
  "description": "Visual testing solution to avoid visual regression. The core component of Argos SDK that handles build creation.",
4
- "version": "1.4.2-alpha.6+505aabe",
4
+ "version": "1.5.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "types": "./dist/index.d.ts",
@@ -59,5 +59,5 @@
59
59
  "build": "rollup -c",
60
60
  "e2e": "node ./e2e/upload.cjs && node ./e2e/upload.mjs"
61
61
  },
62
- "gitHead": "505aabe2ed2b8455172e9a8a473bccf683591a7c"
62
+ "gitHead": "140f6598e42c90fcaa929fd213fadea15b0f5f3d"
63
63
  }