-
Notifications
You must be signed in to change notification settings - Fork 1
46 lines (42 loc) · 1.35 KB
/
sync-metadata.yml
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
name: Overwrite GitHub repo metadata with info from package.json
on:
push:
branches: [main]
jobs:
build:
name: Sync Metadata
runs-on: ubuntu-latest
env:
IS_VALID_TOKEN: false
HAS_PACKAGE: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for package.json
run: |
if [ -f package.json ]; then
echo "📦 Found package.json"
echo "HAS_PACKAGE=true" >> $GITHUB_ENV
else
echo "❌ This action requires a package.json to run"
echo "HAS_PACKAGE=false" >> $GITHUB_ENV
fi
- name: Validate Access Token
if: env.HAS_PACKAGE == 'true'
run: |
if [ -z ${{ secrets.PERSONAL_ACCESS_TOKEN }} ]; then
echo "❌ This action requires a Personal Access token to run"
echo "IS_VALID_TOKEN=false" >> $GITHUB_ENV
else
echo "🔑 Authenticated with Personal Access token"
echo "IS_VALID_TOKEN=true" >> $GITHUB_ENV
fi
- name: Sync Package info to GitHub
if: env.IS_VALID_TOKEN == 'true' && env.HAS_PACKAGE == 'true'
uses: kbrashears5/github-action-repo-sync@v2.0.0
with:
TYPE: npm
PATH: package.json
TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}