diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..b30b2a2 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -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 }}"}}' diff --git a/.github/workflows/create-release-for-fv.yaml b/.github/workflows/create-release-for-fv.yaml deleted file mode 100644 index 94a2547..0000000 --- a/.github/workflows/create-release-for-fv.yaml +++ /dev/null @@ -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"