This commit is contained in:
Lost Paul 2025-02-24 09:15:55 +01:00
commit a3a306c9cf
2 changed files with 66 additions and 102 deletions

66
.github/workflows/build-and-push.yml vendored Normal file
View file

@ -0,0 +1,66 @@
name: Build and Push to Folder Overview
on:
workflow_dispatch:
inputs:
tag:
description: "Tag to build"
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout folder-notes
uses: actions/checkout@v3
with:
submodules: false
fetch-depth: 0
- name: Update submodules manually
run: |
git submodule sync
git submodule update --init --recursive --remote
- name: Install dependencies
run: npm install
- name: Build folder-overview
run: npm run fv-build
- name: Verify build output
run: |
ls -la src/obsidian-folder-overview/
- name: Checkout folder-overview
uses: actions/checkout@v3
with:
repository: LostPaul/obsidian-folder-overview
token: ${{ secrets.PAT }}
ref: main
path: folder-overview
- name: Copy built files to folder-overview
run: |
cp src/obsidian-folder-overview/main.js \
src/obsidian-folder-overview/styles.css folder-overview/
- name: Commit and push built files
run: |
cd folder-overview
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add main.js styles.css
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Add built files for release"
git push origin main
fi
- name: Trigger release on folder-overview
run: |
curl -X POST -H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/LostPaul/obsidian-folder-overview/actions/workflows/release.yml/dispatches \
-d '{"ref": "main", "inputs": {"tag": "${{ github.event.inputs.tag }}"}}'

View file

@ -1,102 +0,0 @@
name: Build and Push to Folder Overview
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
inputs:
tag:
description: "Tag to build"
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# Checkout folder-notes repository
- name: Checkout folder-notes
uses: actions/checkout@v3
with:
repository: LostPaul/obsidian-folder-notes
fetch-depth: 0
submodules: recursive
path: folder-notes
# Install dependencies and run the fv-build process
- name: Run npm install and build in folder-notes
run: |
cd folder-notes
npm install
npm run fv-build
# Verify that the built files exist
- name: Check built files
run: |
ls -la folder-notes/src/obsidian-folder-overview/
# Checkout folder-overview repository on the main branch
- name: Checkout folder-overview
uses: actions/checkout@v3
with:
repository: LostPaul/obsidian-folder-overview
token: ${{ secrets.PAT }}
ref: main # Ensures we are on the main branch
path: folder-overview
# Ensure we're on the main branch
- name: Ensure we are on main branch
run: |
cd folder-overview
git checkout main || git checkout -b main
# Copy the built files from folder-notes to folder-overview
- name: Copy built files to folder-overview
run: |
cp folder-notes/src/obsidian-folder-overview/main.js \
folder-notes/src/obsidian-folder-overview/styles.css folder-overview/
# Commit and push built files only if they changed
- name: Commit and push built files
run: |
cd folder-overview
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add main.js styles.css
# Only commit if there are changes
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "Add built files for release"
git push origin main
fi
# Trigger release workflow in folder-overview
- name: Trigger release workflow in folder-overview
run: |
curl -X POST -H "Authorization: token ${{ secrets.PAT }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/LostPaul/obsidian-folder-overview/actions/workflows/release.yaml/dispatches \
-d '{"ref": "main", "inputs": {"tag": "${{ github.ref_name }}"}}'
cleanup:
needs: build-and-push
runs-on: ubuntu-latest
steps:
# Checkout folder-overview again for cleanup
- name: Checkout folder-overview for cleanup
uses: actions/checkout@v3
with:
repository: LostPaul/obsidian-folder-overview
token: ${{ secrets.PAT }}
ref: main
path: folder-overview
# Remove built files after release
- name: Remove built files after release
run: |
cd folder-overview
git rm -f main.js styles.css || true
git commit -m "Cleanup built files after release" || echo "No changes to commit"
git push origin main || echo "No changes to push"