-
Notifications
You must be signed in to change notification settings - Fork 1
90 lines (79 loc) · 3.45 KB
/
update_plugininfo.yml
File metadata and controls
90 lines (79 loc) · 3.45 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
name: Auto-update plugin card on website
on:
workflow_dispatch:
push:
branches: [feature/auto_plugininfo_on_website]
paths:
- '.github/workflows/update_plugininfo.yml'
- 'scripts/update_plugininfo.py'
jobs:
update-card:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo (plugin source picked automatically)
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install Python dependencies
run: pip install requests pyyaml
- name: Get repo name (lowercase) and run script
run: |
REPO_NAME=$(basename "${{ github.repository }}") # e.g., Scatterplot
REPO_NAME_LC="${REPO_NAME,,}" # scatterplot
echo "Running from repo: $REPO_NAME"
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV # export for later steps
echo "REPO_NAME_LC=$REPO_NAME_LC" >> $GITHUB_ENV
python scripts/update_plugininfo.py "$REPO_NAME"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub App installation token (website repo)
id: app_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ vars.MV_REPO_AUTH_APP_ID }}
private-key: ${{ secrets.MV_REPO_AUTH_PVT_KEY }}
owner: ManiVaultStudio
repositories: manivaultstudio.github.io # ensure the App is installed on this repo with Contents: write
- name: List repos accessible to this installation token
env:
APP_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
curl -s -H "Authorization: Bearer ${APP_TOKEN}" -H "Accept: application/vnd.github+json" \
https://api.github.com/installation/repositories | jq -r '.repositories[].full_name'
- name: Can token read repo via REST?
env:
APP_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
set -e
curl -sfL -H "Authorization: Bearer ${APP_TOKEN}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/ManiVaultStudio/manivaultstudio.github.io \
| jq '.full_name,.private'
echo "✅ REST access OK"
# clone with the app token (note the x-access-token:<token>@ form)
- name: Clone manivaultstudio.github.io (feature branch)
env:
APP_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
git clone --branch ft/test-plugin-push \
https://x-access-token:${APP_TOKEN}@github.com/ManiVaultStudio/manivaultstudio.github.io.git \
target-repo
cp "${REPO_NAME_LC}.md" target-repo/_plugins/
if [ -f "target-repo/_plugins/${REPO_NAME_LC}.md" ]; then
echo "Target file ${REPO_NAME_LC}.md found in _plugins/"
else
echo "Target file ${REPO_NAME_LC}.md not found in _plugins/"
exit 1
fi # quick sanity
- name: Commit and push
env:
APP_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
cd target-repo
git config user.name "manivault-bot[app]"
git config user.email "manivault-bot@users.noreply.github.com"
git add "_plugins/${REPO_NAME_LC}.md"
git commit -m "🔄 Auto-update plugin card from ${REPO_NAME}"
git push origin ft/test-plugin-push