-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
96 lines (90 loc) · 3.1 KB
/
action.yml
File metadata and controls
96 lines (90 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: "Ghost GitHub Portfolio"
description: "Auto-sync GitHub repositories to a Ghost CMS portfolio page"
author: "GeiserX"
branding:
icon: "layout"
color: "purple"
inputs:
config-path:
description: "Path to the config YAML file"
required: false
default: "config.yml"
ghost-url:
description: "Ghost blog URL (overrides config)"
required: false
ghost-admin-api-key:
description: "Ghost Admin API key in KEY_ID:SECRET format"
required: false
ghost-page-slug:
description: "Ghost page slug to update"
required: false
github-username:
description: "GitHub username to fetch repos for"
required: false
min-stars:
description: "Minimum stars to include a repo"
required: false
default: ""
runs:
using: "composite"
steps:
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22"
- name: Install and build
shell: bash
working-directory: ${{ github.action_path }}
run: |
npm ci
npm run build
- name: Generate config overrides
shell: bash
id: config
working-directory: ${{ github.action_path }}
env:
GGP_CONFIG: ${{ github.workspace }}/${{ inputs.config-path }}
GGP_GHOST_URL: ${{ inputs.ghost-url }}
GGP_GHOST_PAGE_SLUG: ${{ inputs.ghost-page-slug }}
GGP_GITHUB_USERNAME: ${{ inputs.github-username }}
GGP_MIN_STARS: ${{ inputs.min-stars }}
run: |
CONFIG="$GGP_CONFIG"
if [ -n "$GGP_GHOST_URL" ] || [ -n "$GGP_GHOST_PAGE_SLUG" ] || [ -n "$GGP_GITHUB_USERNAME" ] || [ -n "$GGP_MIN_STARS" ]; then
cp "$CONFIG" /tmp/ggp-config.yml
CONFIG=/tmp/ggp-config.yml
node -e '
const fs = require("fs");
const yaml = require("yaml");
const c = yaml.parse(fs.readFileSync(process.env.GGP_CONFIG, "utf8")) || {};
if (process.env.GGP_GHOST_URL) {
c.ghost = c.ghost || {};
c.ghost.url = process.env.GGP_GHOST_URL;
}
if (process.env.GGP_GHOST_PAGE_SLUG) {
c.ghost = c.ghost || {};
c.ghost.pageSlug = process.env.GGP_GHOST_PAGE_SLUG;
}
if (process.env.GGP_GITHUB_USERNAME) {
c.github = c.github || {};
c.github.username = process.env.GGP_GITHUB_USERNAME;
}
if (process.env.GGP_MIN_STARS) {
const n = Number.parseInt(process.env.GGP_MIN_STARS, 10);
if (!Number.isFinite(n)) throw new Error("min-stars must be an integer");
c.portfolio = c.portfolio || {};
c.portfolio.minStars = n;
}
fs.writeFileSync("/tmp/ggp-config.yml", yaml.stringify(c));
'
fi
echo "config=$CONFIG" >> "$GITHUB_OUTPUT"
- name: Sync portfolio
shell: bash
env:
GHOST_ADMIN_API_KEY: ${{ inputs.ghost-admin-api-key }}
GHOST_GITHUB_TOKEN: ${{ github.token }}
run: |
node ${{ github.action_path }}/dist/index.js sync \
--config "${{ steps.config.outputs.config }}" \
--verbose