deploy.yml
1 # Sample workflow for building and deploying a VitePress site to GitHub Pages 2 # 3 name: Deploy VitePress site to Codeberg Pages 4 5 on: 6 # Runs on pushes targeting the `main` branch. Change this to `master` if you're 7 # using the `master` branch as the default branch. 8 push: 9 branches: [main] 10 11 # Allows you to run this workflow manually from the Actions tab 12 workflow_dispatch: 13 14 # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 15 # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 16 concurrency: 17 group: pages 18 cancel-in-progress: false 19 20 jobs: 21 # Build job 22 build: 23 runs-on: debian-latest 24 steps: 25 - name: Checkout 26 uses: actions/checkout@v3 27 with: 28 fetch-depth: 0 # Not needed if lastUpdated is not enabled 29 # - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm 30 # - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun 31 - name: Setup Node 32 uses: actions/setup-node@v3 33 with: 34 node-version: 18 35 - run: npm i --frozen-lockfile 36 - name: Install dependencies 37 run: npm ci # or pnpm install / yarn install / bun install 38 - name: Build with VitePress 39 run: | 40 npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build 41 touch web/.vitepress/dist/.nojekyll 42 - name: Upload generated files 43 uses: https://code.forgejo.org/actions/upload-artifact@v3 44 with: 45 name: Generated files 46 path: ./web/.vitepress/dist 47 include-hidden-files: true 48 49 deploy: 50 needs: [ build ] 51 runs-on: debian-latest 52 steps: 53 - name: Clone the repository 54 uses: https://code.forgejo.org/actions/checkout@v4 55 with: 56 submodules: recursive 57 fetch-depth: 0 58 - name: Checkout the target branch and clean it up 59 run: | 60 git checkout pages || git switch --orphan pages && \ 61 rm -Rfv $(ls -A | egrep -v '^(\.git|LICENSE)$') 62 - name: Download generated files 63 uses: https://code.forgejo.org/actions/download-artifact@v3 64 with: 65 name: Generated files 66 - name: Publish the website 67 run: | 68 git config user.email codeberg-ci && \ 69 git config user.name "Codeberg CI" && \ 70 git add . && \ 71 git commit --allow-empty --message "Codeberg build for ${GITHUB_SHA}" && \ 72 git push origin pages