Add GitHub Actions workflow for deploying to GitHub Pages #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [ "main" ] # Поменяйте на master, если нужно | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # РЕКУРСИВНЫЙ ХАК ДЛЯ ВСЕХ JS И HTML ФАЙЛОВ: | |
| - name: Inject repository name into absolute paths | |
| run: | | |
| TARGET_FOLDERS="apriltag|argrid|cimbar|css|img|jabcode|js|lottie|vendor" | |
| REPO_NAME="visual-transfer-protocol" | |
| echo "Запущена автозамена путей для папок: $TARGET_FOLDERS" | |
| find public/app -type f \( -name "*.html" -o -name "*.js" \) -exec sed -E -i "s#\"/($TARGET_FOLDERS)/#\"/$REPO_NAME/\1/#g" {} + | |
| find public/app -type f \( -name "*.html" -o -name "*.js" \) -exec sed -E -i "s#'/($TARGET_FOLDERS)/#'/$REPO_NAME/\1/#g" {} + | |
| find public/app -type f \( -name "*.html" -o -name "*.js" \) -exec sed -E -i "s#\`/($TARGET_FOLDERS)/#\`/$REPO_NAME/\1/#g" {} + | |
| echo "Замена завершена " | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'public/app' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |