From 155fa84eda592002cf628ba0d486474915f4a870 Mon Sep 17 00:00:00 2001 From: Staninna <26458805+Staninna@users.noreply.github.com> Date: Mon, 25 Aug 2025 20:28:48 +0200 Subject: [PATCH] ci?? --- .github/workflows/deploy.yml | 187 +++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..b7f9f1d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,187 @@ +name: Continuous Deployment + +on: + push: + branches: + - "**" + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + actions: read + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + build_matrix: + runs-on: ubuntu-latest + outputs: + json_branches: ${{ steps.generate-matrix.outputs.json_branches }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generate Matrix + id: generate-matrix + run: | + branches=($(git branch -r | cut -c 3- | sed 's/origin\///g')) + json_branches=$(printf '%s\n' "${branches[@]}" | jq -R . | jq -s -c .) + echo "json_branches=${json_branches}" >> $GITHUB_OUTPUT + + collect_files: + runs-on: ubuntu-latest + name: Collect Files + needs: + - build_matrix + strategy: + matrix: + branch: ${{ fromJSON(needs.build_matrix.outputs.json_branches) }} + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ matrix.branch }} + - name: Collect all files + run: | + mkdir -p branch_files + # Copy all JS, CSS, and other relevant files + find . -name "*.js" -not -path "./.git/*" -not -path "./node_modules/*" -not -path "./.github/*" -exec cp {} branch_files/ \; + find . -name "*.css" -not -path "./.git/*" -not -path "./node_modules/*" -not -path "./.github/*" -exec cp {} branch_files/ \; + find . -name "*.json" -not -path "./.git/*" -not -path "./node_modules/*" -not -path "./.github/*" -not -name "package*.json" -exec cp {} branch_files/ \; + find . -name "*.html" -not -path "./.git/*" -not -path "./node_modules/*" -not -path "./.github/*" -exec cp {} branch_files/ \; + # Copy any other asset files you might need + find . -name "*.png" -o -name "*.jpg" -o -name "*.gif" -o -name "*.svg" | grep -v ".git" | grep -v "node_modules" | xargs -I {} cp {} branch_files/ 2>/dev/null || true + ls -la branch_files/ + - uses: actions/upload-artifact@v3 + with: + name: branch-${{ matrix.branch }}-${{ strategy.job-index }} + path: branch_files/ + + deploy: + runs-on: ubuntu-latest + name: Deploy + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: + - build_matrix + - collect_files + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Pages + uses: actions/configure-pages@v3 + - run: gh run download ${{ github.run_id }} --dir branches + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create public folder structure + run: | + mkdir public + cd public + branches=$(echo '${{ needs.build_matrix.outputs.json_branches }}' | jq -r '.[]') + i=0 + + # Create index.html header + cat > index.html << 'EOF' + + +
+ + +Access files from different branches. Click on file links or copy the bookmarklet code:
+ EOF + + for branch in ${branches} + do + # Create branch directory + mkdir -p "$branch" + + # Find and move the branch files + find ../branches -name "branch-${branch}-*" -type d | head -1 | while read dir; do + if [ -d "$dir" ]; then + cp -r "$dir"/* "./$branch/" + fi + done + + # Add branch section to index.html + echo "javascript:fetch(\"https://\${GITHUB_USERNAME}.github.io/\${REPO_NAME}/$branch/$filename\").then(t=>t.text()).then(eval);" >> index.html
+ echo "" >> index.html
+ echo "