Skip to content

feat: add sitemap integration and update header links for trailing sl… #10

feat: add sitemap integration and update header links for trailing sl…

feat: add sitemap integration and update header links for trailing sl… #10

Workflow file for this run

name: Deploy Astro site to GitHub Pages
on:
# Jalankan workflow setiap kali ada push ke branch main
push:
branches: ["main"]
# Memungkinkan Anda untuk menjalankan workflow secara manual dari tab Actions
workflow_dispatch:
# Set izin untuk job ini
permissions:
contents: write # Ubah dari 'read' menjadi 'write' untuk memungkinkan push ke repository
pages: write
id-token: write
# Hanya izinkan satu deployment concurrent
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
build:
name: Build Astro
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Setup PNPM
uses: pnpm/action-setup@v2
with:
version: 8
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build Astro site
run: pnpm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
name: Deploy to GitHub Pages
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
- name: Checkout repository (for pushing to gh-pages branch)
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }} # Gunakan GITHUB_TOKEN untuk otentikasi
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: github-pages
path: ./temp-dist
- name: Extract artifact
run: |
mkdir -p ./extracted
tar -xf ./temp-dist/artifact.tar -C ./extracted
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Update gh-pages branch
run: |
git checkout gh-pages
# Hapus file existing kecuali .git dan extracted
find . -mindepth 1 -maxdepth 1 -not -name ".git" -not -name "extracted" -exec rm -rf {} \;
# Salin semua file dari folder extracted
cp -r ./extracted/* ./
# Periksa apakah ada folder extracted di root, jika ada, hapus
if [ -d "./extracted" ]; then rm -rf ./extracted; fi
git add -A
git commit -m "Update GitHub Pages site from master branch" || echo "No changes to commit"
git push