Update .github/workflows/build.yml
Some checks failed
build.yml / Update .github/workflows/build.yml (push) Failing after 0s
Some checks failed
build.yml / Update .github/workflows/build.yml (push) Failing after 0s
This commit is contained in:
parent
c011eacfa7
commit
7d6a48ab40
1 changed files with 33 additions and 69 deletions
88
.github/workflows/build.yml
vendored
88
.github/workflows/build.yml
vendored
|
|
@ -1,69 +1,33 @@
|
||||||
name: Build Eleventy
|
- name: Publish to forgejo-pages
|
||||||
|
if: github.ref == 'refs/heads/main'
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
git config --global user.name "Forgejo Actions"
|
||||||
|
git config --global user.email "actions@localhost"
|
||||||
|
|
||||||
on:
|
# Build authenticated clone URL
|
||||||
push:
|
REPO_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||||
branches:
|
AUTH_URL="$(echo "$REPO_URL" | sed "s#^https://#https://oauth2:${TOKEN}@#")"
|
||||||
- main
|
|
||||||
paths-ignore:
|
|
||||||
- 'maintenance/**'
|
|
||||||
- 'README.md'
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- 'maintenance/**'
|
|
||||||
- 'README.md'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
git clone "$AUTH_URL" deploy
|
||||||
build:
|
cd deploy
|
||||||
runs-on:
|
|
||||||
- arch-linux
|
|
||||||
|
|
||||||
steps:
|
git fetch origin forgejo-pages || true
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Set up Node.js
|
if git ls-remote --exit-code --heads origin forgejo-pages >/dev/null 2>&1; then
|
||||||
uses: actions/setup-node@v4
|
git checkout -B forgejo-pages origin/forgejo-pages
|
||||||
with:
|
else
|
||||||
node-version: "24"
|
git checkout --orphan forgejo-pages
|
||||||
|
git rm -rf . || true
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Install dependencies
|
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Build site
|
cp -a ../docs/. .
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Publish to forgejo-pages
|
git add -A
|
||||||
if: github.ref == 'refs/heads/main'
|
if ! git diff --cached --quiet; then
|
||||||
env:
|
git commit -m "Deploy ${GITHUB_SHA}"
|
||||||
TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
git push origin forgejo-pages
|
||||||
REPO_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
fi
|
||||||
run: |
|
|
||||||
git config --global user.name "Forgejo Actions"
|
|
||||||
git config --global user.email "actions@localhost"
|
|
||||||
|
|
||||||
# Clone repository
|
|
||||||
git clone "https://oauth2:${TOKEN}@${REPO_URL#https://}" deploy
|
|
||||||
cd deploy
|
|
||||||
|
|
||||||
# Checkout or create forgejo-pages
|
|
||||||
git fetch origin forgejo-pages || true
|
|
||||||
if git ls-remote --exit-code --heads origin forgejo-pages >/dev/null 2>&1; then
|
|
||||||
git checkout -B forgejo-pages origin/forgejo-pages
|
|
||||||
else
|
|
||||||
git checkout --orphan forgejo-pages
|
|
||||||
git rm -rf . || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove old files
|
|
||||||
find . -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
|
||||||
|
|
||||||
# Copy new site
|
|
||||||
cp -a ../docs/. .
|
|
||||||
|
|
||||||
# Commit and push if changed
|
|
||||||
git add -A
|
|
||||||
if ! git diff --cached --quiet; then
|
|
||||||
git commit -m "Deploy ${GITHUB_SHA}"
|
|
||||||
git push origin forgejo-pages
|
|
||||||
fi
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue