-
-
Notifications
You must be signed in to change notification settings - Fork 2
68 lines (56 loc) · 2.18 KB
/
deploy_github_pages.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Workflow for deploying static content to GitHub Pages
name: Deploy GitHub Pages
on:
# Trigger workflow on pushes to the 'main' branch for changes in 'FRONTEND' or workflow files
push:
branches:
- main
paths:
- 'FRONTEND/**'
# Allow manual trigger from the Actions tab
workflow_dispatch:
permissions:
contents: read # Read access to repository content
pages: write # Write access to GitHub Pages
id-token: write # ID token for secure Pages deployment
# Prevent overlapping deployments to GitHub Pages
concurrency:
group: pages-deployments
cancel-in-progress: false
jobs:
deploy:
# Define environment for GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Use the latest Ubuntu runner
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 1 # Optimize fetch to speed up the job
# Step 2: Setup GitHub Pages
- name: Setup GitHub Pages
uses: actions/configure-pages@v5
# Step 3: Update API Path in 'render.js'
- name: Update API Path in render.js
run: |
echo "Replacing local API path with live URL..."
REPO_URL="https://raw.githubusercontent.com"
REPO_NAME="${{ github.repository }}"
DEFAULT_BRANCH="${{ github.event.repository.default_branch }}"
REPO_OWNER_LOWER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
# Use sed to update the file
sed -i "s|../DATA/API/ptprashanttripathi|${REPO_URL}/${REPO_NAME}/${DEFAULT_BRANCH}/DATA/API/${REPO_OWNER_LOWER}|" ./FRONTEND/asset/js/render.js
# Step 4: Upload static site content from the 'FRONTEND' directory
- name: Upload Static Site Content
uses: actions/upload-pages-artifact@v3
with:
path: './FRONTEND/' # Path to the static files
retention-days: 5 # Retain artifacts for 5 days
# Step 5: Deploy the uploaded artifact to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4