-
Notifications
You must be signed in to change notification settings - Fork 4
148 lines (126 loc) · 4.71 KB
/
install.yml
File metadata and controls
148 lines (126 loc) · 4.71 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: 🚀 Install & Deploy GitHub Pages Site
on:
push:
branches: ["master", "gh-pages"]
paths:
- "**/*.html"
- "**/*.css"
- "**/*.js"
- "**/*.json"
- ".github/workflows/install.yml"
workflow_dispatch:
inputs:
ref:
description: "checkout branch or commit"
required: true
default: "master"
permissions: write-all
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: "github-pages"
url: ${{ steps.deployment.outputs.page_url }}
env:
NODE_OPTIONS: "--max_old_space_size=8192" #8192 4096 --expose-gc
YARN_ENABLE_IMMUTABLE_INSTALLS: false
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN || secrets.GITHUB_TOKEN || github.token }}
node-version: 20.x
YARN_CHECKSUM_BEHAVIOR: update
steps:
- name: ⬇️ Checkout Repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.inputs.ref }}
token: ${{ env.ACCESS_TOKEN }}
submodules: recursive
- name: 🛠️ Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.node-version }}
# - name: ⬇️ Download .yarnrc.yml Template
# run: |
# curl -L https://raw.githubusercontent.com/dimaslanjaka/nodejs-package-types/refs/heads/main/.yarnrc-template.yml -o .yarnrc.yml
- name: ⚙️ Enable Corepack & Update NPM
run: |
corepack enable
npm install -g npm@latest
- name: 🔄 Update Git Submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive
yarn dlx rimraf .git/modules
yarn dlx binary-collections@https://raw.githubusercontent.com/dimaslanjaka/bin/master/releases/bin.tgz submodule-install
- name: ♻️ Initialize Cache
uses: actions/cache@v5
with:
path: |
**/yarn.lock
**/package-lock.json
**/.yarn/**
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/package-lock.json', 'package.json', '.husky/hash.txt') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/package-lock.json', 'package.json', '.husky/hash.txt') }}
- name: 🧪 Install GitHub Actions Validator (Try Once)
id: install_validator
run: |
yarn install || (
echo "Validator install failed. Retrying with clean install..."
: > yarn.lock
yarn cache clean --all
rm -rf node_modules
yarn install
)
working-directory: github-actions
- name: 🔧 Configure Git & Normalize Line Endings
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git config core.eol lf
git config core.autocrlf input
git checkout-index --force --all
- name: 📝 Normalize File Names (Casing)
shell: bash
run: |
# Remove everything from index
git rm -r --cached .
# Re-add everything
git add --all
# Explicitly re-add submodules (they won't be re-added by --all if just their ref changed)
submodules=$(git config --file .gitmodules --get-regexp path | awk '{ print $2 }')
for sm in $submodules; do
git add "$sm" || true
done
# Commit if there are any staged changes
if [ "$(git diff --cached --quiet || echo changed)" = "changed" ]; then
git commit -m "fix: file name casing"
fi
- name: 🧹 Clean & Reinstall Production Dependencies
shell: bash
run: |
bash -e scripts/setup.sh
- name: ✅ Validate Paths & Structure
id: validate
run: node github-actions/index.js
- name: 🗑️ Cleanup Unused & Temporary Files
run: |
rm -rf github-actions .devcontainer .npmrc .gitmodules github-actions-validator.config.yml
find . -type d \( -name '.github' -o -name '.vscode' -o -name 'tmp' \) -exec rm -rf '{}' +
- name: 📄 Setup GitHub Pages
if: steps.validate.outcome == 'success'
uses: actions/configure-pages@v6
- name: ⬆️ Upload Pages Artifact
if: steps.validate.outcome == 'success'
uses: actions/upload-pages-artifact@v5
with:
path: "."
name: "github-pages"
- name: 🚀 Deploy to GitHub Pages
if: steps.validate.outcome == 'success'
id: deployment
uses: actions/deploy-pages@v5
with:
token: ${{ env.ACCESS_TOKEN }}
artifact_name: "github-pages"