ci: autogenerated changes #263
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: Continuous Integration | |
on: | |
push: | |
branches: main | |
pull_request: | |
branches: main | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v2 | |
- run: deno task lint | |
quick-test: | |
name: Quick test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v2 | |
- run: deno task install:deno | |
- run: deno task test:deno | |
test: | |
name: Test | |
runs-on: ${{ matrix.os }} | |
needs: | |
- lint | |
- quick-test | |
permissions: | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
runtime: | |
- name: deno | |
version: 2.x | |
- name: node | |
version: 22.x | |
- name: bun | |
# https://github.com/oven-sh/setup-bun/issues/37 | |
# version: 1.x | |
version: latest | |
os: | |
- ubuntu-latest | |
# - windows-latest | |
- macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v2 | |
- if: matrix.runtime.name == 'deno' | |
uses: denoland/setup-deno@v2 | |
with: | |
deno-version: ${{ matrix.runtime.version }} | |
- if: matrix.runtime.name == 'node' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.runtime.version }} | |
- if: matrix.runtime.name == 'bun' | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: ${{ matrix.runtime.version }} | |
- run: deno task install:${{ matrix.runtime.name }} | |
- run: deno task test:${{ matrix.runtime.name }} | |
preview: | |
name: Preview | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- quick-test | |
permissions: | |
id-token: write | |
contents: read | |
environment: | |
name: preview | |
url: ${{ steps.preview.outputs.url }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v2 | |
- run: deno task ci:setup-deno-deploy | |
id: setup_github_actions | |
- run: deno task install:deno | |
- uses: denoland/deployctl@v1 | |
id: preview | |
# https://github.com/denoland/deployctl/issues/350 | |
with: | |
project: ${{ steps.setup_github_actions.outputs.project }} | |
entrypoint: ${{ steps.setup_github_actions.outputs.entrypoint }} | |
import-map: ${{ steps.setup_github_actions.outputs.import_map }} | |
include: ${{ steps.setup_github_actions.outputs.include }} | |
exclude: ${{ steps.setup_github_actions.outputs.exclude }} | |
autogenerate: | |
name: Autogenerate | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
# needs: | |
# - test | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/create-github-app-token@v1 | |
id: autogenerated | |
with: | |
app-id: 1090539 | |
private-key: ${{ secrets.AUTOGENERATED_CONTENT_PRIVATE_KEY }} | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.autogenerated.outputs.token }} | |
- uses: denoland/setup-deno@v2 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
- run: deno task ci:autogenerate | |
- name: Run git push | |
run: | | |
if [ -n "$(git status --porcelain)" ]; then | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git diff | |
git add . | |
git commit -m 'ci: autogenerated changes' | |
git pull --rebase | |
git push | |
fi | |
publish: | |
name: Publish | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: | |
- autogenerate | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: denoland/setup-deno@v2 | |
- run: deno publish | |
deploy: | |
name: Deploy | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
needs: | |
- preview | |
- publish | |
permissions: | |
id-token: write | |
pages: write | |
environment: | |
name: deployment | |
url: ${{ steps.deployment.outputs.url }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: main | |
- uses: actions/configure-pages@v5 | |
- uses: denoland/setup-deno@v2 | |
- run: deno task ci:setup-github-pages | |
- uses: actions/upload-pages-artifact@v3 | |
- uses: actions/deploy-pages@v4 | |
id: deployment |