Skip to content

Commit

Permalink
fix: css link added throught github action
Browse files Browse the repository at this point in the history
  • Loading branch information
CA-MKSingh committed Oct 24, 2024
1 parent 40bc652 commit bc09125
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
24 changes: 24 additions & 0 deletions .github/scripts/update-css-link.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Find the CSS file in the assets directory
CSS_FILE=$(find ./build/client/assets -name "root*.css" -type f)

if [ -z "$CSS_FILE" ]; then
echo "No CSS file found in ./build/client/assets"
exit 1
fi

# Get just the filename from the path
CSS_FILENAME=$(basename "$CSS_FILE")

# Update the index.html file to include the CSS link
# First, check if a CSS link already exists
if grep -q "<link.*rel=\"stylesheet\".*>" ./build/client/index.html; then
# Update existing CSS link
sed -i "s|<link.*rel=\"stylesheet\".*>|<link rel=\"stylesheet\" href=\"/assets/$CSS_FILENAME\">|" ./build/client/index.html
else
# Add new CSS link before closing head tag
sed -i "s|</head>|<link rel=\"stylesheet\" href=\"/assets/$CSS_FILENAME\">\n</head>|" ./build/client/index.html
fi

echo "Updated index.html with CSS link: $CSS_FILENAME"
21 changes: 4 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,16 @@
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches: ['trunk']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
Expand All @@ -30,26 +19,24 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Build
run: bun run build

- name: Update CSS link
run: |
chmod +x .github/scripts/update-css-link.sh
.github/scripts/update-css-link.sh
- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './build/client'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit bc09125

Please sign in to comment.