-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (74 loc) · 3.14 KB
/
Copy pathsetup-blog.yml
File metadata and controls
83 lines (74 loc) · 3.14 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
name: Set Up Blog
# Run this workflow to configure your blog's optional integrations.
# It stores your settings as GitHub Actions repository Variables
# (never committed to source) so every fork starts clean.
#
# How to run:
# Go to Actions → "Set Up Blog" → Run workflow → fill in the inputs → Run.
# The workflow sets the variables and then the next build picks them up.
#
# Prerequisites (one-time, takes ~30 seconds):
# Go to Settings → Actions → General → Workflow permissions and select
# "Read and write permissions". This lets the default GITHUB_TOKEN create
# repository variables — no personal access token needed.
on:
workflow_dispatch:
inputs:
hn_username:
description: >
Hacker News username — enables the "My Reading" section.
Leave blank to skip (or to clear an existing value, enter a single space).
required: false
default: ''
youtube_playlist_ids:
description: >
YouTube playlist ID(s), comma-separated — enables the "My Watching" section.
Find the ID in the playlist URL: youtube.com/playlist?list=PLAYLIST_ID_HERE
Leave blank to skip (or to clear an existing value, enter a single space).
required: false
default: ''
permissions:
actions: write # needed to create / update repository variables
jobs:
configure:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Set HN_USERNAME variable
if: inputs.hn_username != ''
env:
HN_VALUE: ${{ inputs.hn_username }}
run: |
trimmed="${HN_VALUE// /}" # remove all spaces; a lone space input clears the var
if [ -n "$trimmed" ]; then
gh variable set HN_USERNAME --body "$trimmed" --repo "$GITHUB_REPOSITORY"
echo "✅ HN_USERNAME set to: $trimmed"
else
gh variable delete HN_USERNAME --repo "$GITHUB_REPOSITORY" 2>/dev/null || true
echo "🗑️ HN_USERNAME cleared."
fi
- name: Set YOUTUBE_PLAYLIST_IDS variable
if: inputs.youtube_playlist_ids != ''
env:
YT_VALUE: ${{ inputs.youtube_playlist_ids }}
run: |
trimmed="${YT_VALUE// /}" # remove all spaces; a lone space input clears the var
if [ -n "$trimmed" ]; then
gh variable set YOUTUBE_PLAYLIST_IDS --body "$trimmed" --repo "$GITHUB_REPOSITORY"
echo "✅ YOUTUBE_PLAYLIST_IDS set."
else
gh variable delete YOUTUBE_PLAYLIST_IDS --repo "$GITHUB_REPOSITORY" 2>/dev/null || true
echo "🗑️ YOUTUBE_PLAYLIST_IDS cleared."
fi
- name: Show current configuration
run: |
echo ""
echo "Current repository variables:"
gh variable list --repo "$GITHUB_REPOSITORY" || echo "(no variables set)"
echo ""
echo "Run the 'Build and Deploy Blog' workflow (or push any commit) to rebuild your site."
- name: Mark blog as configured
run: |
gh variable set BLOG_CONFIGURED --body "true" --repo "$GITHUB_REPOSITORY"
echo "✅ BLOG_CONFIGURED set."