π₯ Build & Deploy Cookbook #407
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: π₯ Build & Deploy Cookbook | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
push: | |
branches: | |
- main | |
paths: | |
- "src/**" | |
# Perform a release using a workflow dispatch | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# Run the build as part of PRs to confirm the site properly builds | |
check_build: | |
if: ${{ startsWith(github.ref, 'refs/pull/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@v3 | |
- name: β Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: yarn | |
- name: π₯ Download deps | |
run: | | |
yarn --ignore-engines | |
- name: π Build Docs | |
run: | | |
yarn build | |
# Build and deploy the artifacts to Arweave via ArDrive | |
deploy: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these deployments to complete. | |
concurrency: | |
group: deploy | |
cancel-in-progress: false | |
steps: | |
- name: β¬οΈ Checkout repo | |
uses: actions/checkout@v3 | |
- name: β Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: yarn | |
- name: π₯ Download deps | |
run: | | |
yarn --ignore-engines | |
- name: π Env | |
run: | | |
echo "Event name: ${{ github.event_name }}" | |
echo "Git ref: ${{ github.ref }}" | |
echo "GH actor: ${{ github.actor }}" | |
echo "SHA: ${{ github.sha }}" | |
VER=`node --version`; echo "Node ver: $VER" | |
VER=`npm --version`; echo "npm ver: $VER" | |
- name: π Build Docs | |
id: build_artifacts | |
run: | | |
yarn build | |
touch src/.vitepress/dist/.nojekyll | |
ARTIFACTS_HASH=$(sha256sum src/.vitepress/dist/hashmap.json | awk '{ print $1 }') | |
echo "artifacts_output_dir=src/.vitepress/dist" >> $GITHUB_OUTPUT | |
echo "artifacts_hash=${ARTIFACTS_HASH}" >> $GITHUB_OUTPUT | |
- name: πΎ Publish to Arweave | |
id: publish_artifacts | |
run: | | |
npx permaweb-deploy \ | |
--ant-process=${ANT_PROCESS} \ | |
--undername=${UNDERNAME} \ | |
--deploy-folder=${ARTIFACTS_OUTPUT_DIR} | |
env: | |
DEPLOY_KEY: ${{ secrets.CI_WALLET }} | |
ARTIFACTS_HASH: ${{ steps.build_artifacts.outputs.artifacts_hash }} | |
ARTIFACTS_OUTPUT_DIR: ${{ steps.build_artifacts.outputs.artifacts_output_dir }} | |
ANT_PROCESS: YFbfeqZMbPVGFjQ-PHJY-Y99JQu7O3Jdet06pJnD5iI | |
UNDERNAME: cookbook |