Skip to content

Commit 3c7534f

Browse files
feat: added banner and update subscription check to make maintained actions free for public repos
Signed-off-by: Anurag Rajawat <[email protected]>
1 parent 45276d7 commit 3c7534f

9 files changed

Lines changed: 95 additions & 18 deletions

File tree

.github/workflows/actions_release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
tag:
77
description: "Tag for the release"
88
required: true
9+
node_version:
10+
description: "Specify Node.js version (e.g., '18', '20', 'lts/*')"
11+
required: false
12+
default: "24"
913

1014
permissions:
1115
contents: read
@@ -20,3 +24,4 @@ jobs:
2024
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
2125
with:
2226
tag: "${{ github.event.inputs.tag }}"
27+
node_version: "${{ github.event.inputs.node_version }}"

.github/workflows/audit_package.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
description: "Specify a base branch"
1212
required: false
1313
default: "main"
14+
node_version:
15+
description: "Specify Node.js version (e.g., '18', '20', 'lts/*')"
16+
required: false
17+
default: "24"
1418
schedule:
1519
- cron: "0 0 * * 1"
1620

@@ -20,6 +24,7 @@ jobs:
2024
with:
2125
force: ${{ inputs.force || false }}
2226
base_branch: ${{ inputs.base_branch || 'main' }}
27+
node_version: "${{ inputs.node_version || '24' }}"
2328

2429
permissions:
2530
contents: write

.github/workflows/auto_cherry_pick.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
description: "Base branch to create the PR against"
88
required: true
99
default: "main"
10+
node_version:
11+
description: "Specify Node.js version (e.g., '18', '20', 'lts/*')"
12+
required: false
13+
default: "24"
1014

1115
permissions:
1216
contents: write
@@ -21,3 +25,4 @@ jobs:
2125
original-owner: "Bhacaz"
2226
repo-name: "docs-as-code-confluence"
2327
base_branch: ${{ inputs.base_branch }}
28+
node_version: "${{ inputs.node_version || '24' }}"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![StepSecurity Maintained Action](https://raw.githubusercontent.com/step-security/maintained-actions-assets/main/assets/maintained-action-banner.png)](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions)
2+
13
# Docs as Code - Confluence
24

35
Publish a folder of documentation to Confluence.

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ inputs:
2424
description: "Page id under which the documentation will be published"
2525
required: true
2626
runs:
27-
using: "node20"
27+
using: "node24"
2828
main: "dist/index.js"

dist/index.js

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29016,6 +29016,7 @@ const Confluence = __nccwpck_require__(3099);
2901629016
const core = __nccwpck_require__(2186);
2901729017
const parser = __nccwpck_require__(4363)
2901829018
const path = __nccwpck_require__(1017)
29019+
const fs = __nccwpck_require__(7147)
2901929020
const axios = __nccwpck_require__(8757)
2902029021

2902129022
const filesStructure = __nccwpck_require__(8612);
@@ -29086,19 +29087,48 @@ async function handleAttachments(contentPageId, data) {
2908629087
}
2908729088

2908829089
async function validateSubscription() {
29089-
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`;
29090-
29090+
let repoPrivate;
29091+
const eventPath = process.env.GITHUB_EVENT_PATH;
29092+
if (eventPath && fs.existsSync(eventPath)) {
29093+
const payload = JSON.parse(fs.readFileSync(eventPath, "utf8"));
29094+
repoPrivate = payload?.repository?.private;
29095+
}
29096+
29097+
const upstream = "Bhacaz/docs-as-code-confluence";
29098+
const action = process.env.GITHUB_ACTION_REPOSITORY;
29099+
const docsUrl =
29100+
"https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions";
29101+
29102+
core.info("");
29103+
core.info("StepSecurity Maintained Action");
29104+
core.info(`Secure drop-in replacement for ${upstream}`);
29105+
if (repoPrivate === false)
29106+
core.info("✓ Free for public repositories");
29107+
core.info(`Learn more: ${docsUrl}`);
29108+
core.info("");
29109+
29110+
if (repoPrivate === false) return;
29111+
const serverUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
29112+
const body = { action: action || "" };
29113+
29114+
if (serverUrl !== "https://github.com") body.ghes_server = serverUrl;
2909129115
try {
29092-
await axios.get(API_URL, {timeout: 3000});
29116+
await axios.post(
29117+
`https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`,
29118+
body,
29119+
{ timeout: 3000 },
29120+
);
2909329121
} catch (error) {
29094-
if (error.response && error.response.status === 403) {
29095-
console.error(
29096-
'Subscription is not valid. Reach out to [email protected]'
29122+
if (axios.isAxiosError(error) && error.response?.status === 403) {
29123+
core.error(
29124+
`This action requires a StepSecurity subscription for private repositories.`,
29125+
);
29126+
core.error(
29127+
`Learn how to enable a subscription: ${docsUrl}`,
2909729128
);
2909829129
process.exit(1);
29099-
} else {
29100-
core.info('Timeout or API not reachable. Continuing to next step.');
2910129130
}
29131+
core.info("Timeout or API not reachable. Continuing to next step.");
2910229132
}
2910329133
}
2910429134

index.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Confluence = require("confluence-api");
22
const core = require("@actions/core");
33
const parser = require("node-html-parser")
44
const path = require('path')
5+
const fs = require('fs')
56
const axios = require('axios')
67

78
const filesStructure = require("./utils/files");
@@ -72,19 +73,48 @@ async function handleAttachments(contentPageId, data) {
7273
}
7374

7475
async function validateSubscription() {
75-
const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`;
76+
let repoPrivate;
77+
const eventPath = process.env.GITHUB_EVENT_PATH;
78+
if (eventPath && fs.existsSync(eventPath)) {
79+
const payload = JSON.parse(fs.readFileSync(eventPath, "utf8"));
80+
repoPrivate = payload?.repository?.private;
81+
}
82+
83+
const upstream = "Bhacaz/docs-as-code-confluence";
84+
const action = process.env.GITHUB_ACTION_REPOSITORY;
85+
const docsUrl =
86+
"https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions";
87+
88+
core.info("");
89+
core.info("StepSecurity Maintained Action");
90+
core.info(`Secure drop-in replacement for ${upstream}`);
91+
if (repoPrivate === false)
92+
core.info("✓ Free for public repositories");
93+
core.info(`Learn more: ${docsUrl}`);
94+
core.info("");
7695

96+
if (repoPrivate === false) return;
97+
const serverUrl = process.env.GITHUB_SERVER_URL || "https://github.com";
98+
const body = { action: action || "" };
99+
100+
if (serverUrl !== "https://github.com") body.ghes_server = serverUrl;
77101
try {
78-
await axios.get(API_URL, {timeout: 3000});
102+
await axios.post(
103+
`https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`,
104+
body,
105+
{ timeout: 3000 },
106+
);
79107
} catch (error) {
80-
if (error.response && error.response.status === 403) {
81-
console.error(
82-
'Subscription is not valid. Reach out to [email protected]'
108+
if (axios.isAxiosError(error) && error.response?.status === 403) {
109+
core.error(
110+
`This action requires a StepSecurity subscription for private repositories.`,
111+
);
112+
core.error(
113+
`Learn how to enable a subscription: ${docsUrl}`,
83114
);
84115
process.exit(1);
85-
} else {
86-
core.info('Timeout or API not reachable. Continuing to next step.');
87116
}
117+
core.info("Timeout or API not reachable. Continuing to next step.");
88118
}
89119
}
90120

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "step-security",
1212
"license": "MIT",
1313
"engines": {
14-
"node": ">=20"
14+
"node": ">=24"
1515
},
1616
"dependencies": {
1717
"@actions/core": "^1.6.0",

0 commit comments

Comments
 (0)