From 3ea33cc89b900b8d2551b965e757cc18d1dc07c1 Mon Sep 17 00:00:00 2001 From: tdstein Date: Mon, 10 Jun 2024 12:13:03 -0400 Subject: [PATCH] ci: comment site preview --- .github/workflows/docs.yaml | 27 ---------------------- .github/workflows/site.yaml | 45 +++++++++++++++++++++++++++++++++++++ docs/Makefile | 5 +++++ 3 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 .github/workflows/docs.yaml create mode 100644 .github/workflows/site.yaml diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml deleted file mode 100644 index a20c920f..00000000 --- a/.github/workflows/docs.yaml +++ /dev/null @@ -1,27 +0,0 @@ -name: Documentation -on: - - pull_request -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - default: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: 3.x - check-latest: true - cache: 'pip' - - uses: quarto-dev/quarto-actions/setup@v2 - - run: make deps - - run: make dev - - run: make docs - - uses: actions/setup-node@v4 - - run: npx -y netlify-cli deploy --dir docs/_site - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: 5cea1f56-7935-4387-975a-18a7905d15ee diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml new file mode 100644 index 00000000..a3486da8 --- /dev/null +++ b/.github/workflows/site.yaml @@ -0,0 +1,45 @@ +name: Site +on: + - pull_request +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + default: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: 3.x + check-latest: true + cache: 'pip' + - uses: quarto-dev/quarto-actions/setup@v2 + - run: make deps + - run: make dev + - run: make docs + - uses: actions/setup-node@v4 + - id: netlify + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + run: | + preview_url=$(make --silent -C ./docs netlify | tail -n 1) + echo "preview_url=$preview_url" >> $GITHUB_OUTPUT + - uses: actions/github-script@v6 + env: + preview_url: ${{ steps.netlify.outputs.preview_url }} + with: + script: | + const url = process.env.preview_url; + const issue_number = context.payload.pull_request.number; + const repo = context.repo.repo; + const owner = context.repo.owner; + + github.rest.issues.createComment({ + owner, + repo, + issue_number, + body: `🚀 Preview your changes [here](${url})` + }) diff --git a/docs/Makefile b/docs/Makefile index 37100bce..e9bbbe25 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -6,6 +6,7 @@ QUARTO ?= quarto QUARTODOC ?= quartodoc # Environment variables +NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee CURRENT_YEAR ?= $(shell date +%Y) VERSION ?= $(shell make --silent -C ../ version | tail -n 1) @@ -41,3 +42,7 @@ preview: CURRENT_YEAR=$(CURRENT_YEAR) \ VERSION=$(VERSION) \ $(QUARTO) preview + + +netlify: + NETLIFY_SITE_ID=$(NETLIFY_SITE_ID) npx -y netlify-cli deploy --dir _site --json | jq '.deploy_url'