Skip to content

Commit 0c92e09

Browse files
authored
Merge pull request #2 from xandemon/deploy
Deploy Developer-Icons to GitHub Pages
2 parents e8afea3 + 959c6fd commit 0c92e09

File tree

10 files changed

+116
-35
lines changed

10 files changed

+116
-35
lines changed

.github/workflows/astro.yml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,90 @@
22
#
33
# To get started with Astro see: https://docs.astro.build/en/getting-started/
44
#
5-
name: Deploy Astro site to Pages
5+
name: Deploy Developer-Icons to GitHub Pages
66

77
on:
8-
# Trigger the workflow every time you push to the `main` branch
8+
# Runs on pushes targeting the default branch
99
push:
10-
branches: [deploy, main]
11-
# Allows you to run this workflow manually from the Actions tab on GitHub.
10+
branches: ["main"]
11+
12+
# Allows you to run this workflow manually from the Actions tab
1213
workflow_dispatch:
1314

14-
# Allow this job to clone the repo and create a page deployment
15+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1516
permissions:
1617
contents: read
1718
pages: write
1819
id-token: write
1920

21+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
22+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
23+
concurrency:
24+
group: "pages"
25+
cancel-in-progress: false
26+
27+
env:
28+
VITE_PUBLIC_BASE_URL: "/developer-icons"
29+
BUILD_PATH: "docs" # default value when not using subfolders
30+
# BUILD_PATH: subfolder
31+
2032
jobs:
2133
build:
34+
name: Build
2235
runs-on: ubuntu-latest
2336
steps:
24-
- name: Check out your repository using git
25-
uses: actions/checkout@v2
26-
27-
- name: Use Node.js 20
28-
uses: actions/setup-node@v2
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
- name: Detect package manager
40+
id: detect-package-manager
41+
run: |
42+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
43+
echo "manager=yarn" >> $GITHUB_OUTPUT
44+
echo "command=install" >> $GITHUB_OUTPUT
45+
echo "runner=yarn" >> $GITHUB_OUTPUT
46+
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
47+
exit 0
48+
elif [ -f "${{ github.workspace }}/package.json" ]; then
49+
echo "manager=npm" >> $GITHUB_OUTPUT
50+
echo "command=ci" >> $GITHUB_OUTPUT
51+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
52+
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
53+
exit 0
54+
else
55+
echo "Unable to determine package manager"
56+
exit 1
57+
fi
58+
- name: Setup Node
59+
uses: actions/setup-node@v4
2960
with:
3061
node-version: "20"
31-
cache: "npm"
32-
33-
# Not using npm? Change `npm ci` to `yarn install` or `pnpm i`
62+
cache: ${{ steps.detect-package-manager.outputs.manager }}
63+
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}
64+
- name: Setup Pages
65+
id: pages
66+
uses: actions/configure-pages@v5
3467
- name: Install dependencies
35-
run: cd docs && npm ci
36-
37-
# Not using npm? Change `npm run build` to `yarn build` or `pnpm run build`
38-
- name: Build Astro
39-
run: npm run build:docs --if-present
40-
68+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
69+
working-directory: ${{ env.BUILD_PATH }}
70+
- name: Build with Astro
71+
run: |
72+
${{ steps.detect-package-manager.outputs.runner }} astro build \
73+
--site "${{ steps.pages.outputs.origin }}" \
74+
--base "${{ steps.pages.outputs.base_path }}"
75+
working-directory: ${{ env.BUILD_PATH }}
4176
- name: Upload artifact
42-
uses: actions/upload-pages-artifact@v1
77+
uses: actions/upload-pages-artifact@v3
4378
with:
44-
path: ./docs/dist
79+
path: ${{ env.BUILD_PATH }}/dist
4580

4681
deploy:
4782
environment:
4883
name: github-pages
4984
url: ${{ steps.deployment.outputs.page_url }}
50-
runs-on: ubuntu-latest
5185
needs: build
86+
runs-on: ubuntu-latest
87+
name: Deploy
5288
steps:
5389
- name: Deploy to GitHub Pages
5490
id: deployment
55-
uses: actions/deploy-pages@v1
91+
uses: actions/deploy-pages@v4

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test Deploy to GitHub Pages
2+
3+
on:
4+
# Trigger the workflow every time you push to the `main` branch
5+
# Using a different branch name? Replace `main` with your branch’s name
6+
push:
7+
branches: [test]
8+
# Allows you to run this workflow manually from the Actions tab on GitHub.
9+
workflow_dispatch:
10+
11+
# Allow this job to clone the repo and create a page deployment
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout your repository using git
22+
uses: actions/checkout@v4
23+
- name: Install, build, and upload your site
24+
uses: withastro/action@v2
25+
with:
26+
path: ./docs
27+
node-version: 20
28+
package-manager: npm@latest
29+
# with:
30+
# path: . # The root location of your Astro project inside the repository. (optional)
31+
# node-version: 20 # The specific version of Node that should be used to build your site. Defaults to 20. (optional)
32+
# package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
33+
34+
deploy:
35+
needs: build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: github-pages
39+
url: ${{ steps.deployment.outputs.page_url }}
40+
steps:
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

docs/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_PUBLIC_BASE_URL=/developer-icons/docs

docs/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ yarn-error.log*
1414
pnpm-debug.log*
1515

1616
# environment variables
17-
.env
1817
.env.production
1918

2019
# macOS-specific files

docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import tailwind from "@astrojs/tailwind";
77
export default defineConfig({
88
site: "https://xandemon.github.io",
99
base: "/developer-icons/docs",
10+
publicDir: "./assets",
1011
integrations: [
1112
react(),
1213
tailwind({

docs/src/components/HeroSection.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { ArrowUpRight } from "lucide-react";
33
import { Badge } from "./ui/badge";
44
import { Button } from "./ui/button";
5+
import { publicBaseUrl } from "@/lib/utils";
56
---
67

78
<div class="flex items-center justify-between gap-4 w-full py-4">
@@ -33,7 +34,7 @@ import { Button } from "./ui/button";
3334
</div>
3435

3536
<img
36-
src="/developer-icons/docs/assets/hero-image.png"
37+
src={`${publicBaseUrl}/hero-image.png`}
3738
class="rounded-lg w-full h-[350px] max-w-[45%] object-contain shadow-md shadow-zinc-800"
3839
/>
3940
</div>

docs/src/components/Navbar.astro

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
---
22
import { GithubIcon, NpmIcon } from "developer-icons";
33
import Container from "./Container.astro";
4+
import { publicBaseUrl } from "@/lib/utils";
45
---
56

67
<div class="navbar">
78
<Container className="justify-between">
89
<a href="/" class="flex items-center gap-2">
9-
<img
10-
src="/developer-icons/docs/assets/favicon.svg"
11-
width="30"
12-
height="30"
13-
/>
10+
<img src={`${publicBaseUrl}/favicon.svg`} width="30" height="30" />
1411
<span class="font-semibold text-lg">Developer Icons</span>
1512
</a>
1613
<nav

docs/src/layouts/Layout.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
import Container from "@/components/Container.astro";
33
import Navbar from "@/components/Navbar.astro";
4+
import { publicBaseUrl } from "@/lib/utils";
45
import "@fontsource-variable/noto-sans";
56
67
interface Props {
@@ -22,7 +23,7 @@ const { title } = Astro.props;
2223
<link
2324
rel="icon"
2425
type="image/svg+xml"
25-
href="/developer-icons/docs/assets/favicon.svg"
26+
href={`${publicBaseUrl}/favicon.svg`}
2627
/>
2728
<meta name="generator" content={Astro.generator} />
2829
<title>{title}</title>

docs/src/lib/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { type ClassValue, clsx } from "clsx"
2-
import { twMerge } from "tailwind-merge"
1+
import { type ClassValue, clsx } from "clsx";
2+
import { twMerge } from "tailwind-merge";
3+
4+
export const publicBaseUrl = import.meta.env.VITE_PUBLIC_BASE_URL;
35

46
export function cn(...inputs: ClassValue[]) {
5-
return twMerge(clsx(inputs))
7+
return twMerge(clsx(inputs));
68
}

docs/src/pages/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Layout from "../layouts/Layout.astro";
33
import FeatureSection from "@/components/FeatureSection.astro";
44
import HeroSection from "@/components/HeroSection.astro";
55
import { InstallCmd } from "@/components/ui/installCmd";
6-
import "@/styles/globals.css";
6+
import "../styles/globals.css";
77
---
88

99
<Layout title="Developer Icons by xandemon">

0 commit comments

Comments
 (0)