Skip to content

deploy-github-pages #13

deploy-github-pages

deploy-github-pages #13

name: deploy-github-pages
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Update Submodule
run: git pull --recurse-submodules && git submodule update --remote --recursive --init
- name: Commit Changes
uses: EndBug/add-and-commit@v7
with:
message: 'chore: update git submodules'
default_author: github_actions
- name: Switch to Latest Tag
run: cd lib && git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
- name: Copy CHANGELOG.md
run: cp lib/CHANGELOG.md docs/changelog.md
- name: Copy README.md
run: |
rm -rf docs/intro.md
echo "---" >> docs/intro.md
echo "sidebar_position: 1" >> docs/intro.md
echo "title: 'Welcome'" >> docs/intro.md
echo "sidebar_label: 'Welcome'" >> docs/intro.md
echo "slug: /" >> docs/intro.md
echo "---" >> docs/intro.md
cat lib/README.md >> docs/intro.md
- name: Clone Assets
run: |
git clone https://github.com/Statscell/clash-assets.git
cp clash-assets/troops/icons/* -r static/assets
- name: Install
run: yarn
- name: Build
run: yarn build
- name: README.md
run: |
echo "# Documentation Branch" >> build/README.md
echo "This branch hosts the documentation files used for https://clashofclans.js.org/. No manual commits should ever need to be done to this branch." >> build/README.md
echo "## Commits" >> build/README.md
echo "- [clashperk/clashofclans.js@$(git rev-parse --short HEAD:lib)](https://github.com/clashperk/clashofclans.js/commit/$(git rev-parse HEAD:lib))" >> build/README.md
echo "- [clashperk/clashofclans.js.org@$(git rev-parse --short HEAD)](https://github.com/clashperk/clashofclans.js.org/commit/$(git rev-parse HEAD))" >> build/README.md
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./build
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
publish-github-pages:
needs: generate-docs
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2