modular-avatar/.github/workflows/deploy-pages.yml
dependabot[bot] 55ab65e22d
chore(deps): bump nathanvaughn/actions-cloudflare-purge (#1287)
Bumps [nathanvaughn/actions-cloudflare-purge](https://github.com/nathanvaughn/actions-cloudflare-purge) from cd4afdf666c2e6a6720048f27ac9cbdd664a673a to 992cc4e96422fb8ddf077281678373fe41e7736c.
- [Release notes](https://github.com/nathanvaughn/actions-cloudflare-purge/releases)
- [Commits](cd4afdf666...992cc4e964)

---
updated-dependencies:
- dependency-name: nathanvaughn/actions-cloudflare-purge
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-10-15 19:13:24 -07:00

130 lines
3.5 KiB
YAML

name: Deploy documentation
on:
push:
branches:
- main
- docs-snapshot
- docs-ci-test
workflow_dispatch: {}
release:
types:
- released
concurrency:
group: "pages-cf"
cancel-in-progress: true
jobs:
snapshot-docs:
name: Snapshot documentation
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
# Run on releases only
if: ${{ github.event.release }}
with:
ref: ${{ github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Merge with existing branch
# Run on releases only
if: ${{ github.event.release }}
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@nadena.dev"
git merge -s ours origin/docs-snapshot
git push origin HEAD:docs-snapshot
build-docs:
name: Build documentation (latest release)
uses: bdunderscore/modular-avatar/.github/workflows/build-test-docs.yml@main
needs:
- snapshot-docs
with:
ref: docs-snapshot
build-docs-dev:
name: Build documentation (main branch)
uses: bdunderscore/modular-avatar/.github/workflows/build-test-docs.yml@main
with:
ref: main
path: dev
artifact: docs-dev
deploy-docs:
name: Deploy documentation
needs:
- build-docs
- build-docs-dev
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.ref }}
- name: Download artifact (tagged)
uses: actions/download-artifact@v4
with:
name: docs
path: docs/build
- name: Download artifact (latest)
uses: actions/download-artifact@v4
with:
name: docs-dev
path: docs/build/dev
- name: Dump file listing
run: |
ls -lR docs/build
- name: Unpack documentation
run: |
mkdir -p docs-site~/public/dev
tar -xf docs/build/docs.tar -C docs-site~/public
tar -xf docs/build/dev/docs.tar -C docs-site~/public/dev
- name: Setup yarn 2.0
run: |
corepack enable
corepack prepare yarn@stable --activate
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(cd docs-site~; yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-site-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-site-
- name: Build CF site
run: |
cd docs-site~
YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install
- name: Deploy to Cloudflare Pages
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
command: deploy --name modular-avatar-docs
workingDirectory: docs-site~
- name: Purge cache
uses: nathanvaughn/actions-cloudflare-purge@992cc4e96422fb8ddf077281678373fe41e7736c
continue-on-error: true
with:
cf_zone: ${{ secrets.CF_ZONE_ID }}
cf_auth: ${{ secrets.CF_API_TOKEN }}