Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 29 additions & 67 deletions .github/workflows/build-push-images-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,44 @@
name: Build and Push Images (DEV)
name: PR preview environment
on:
pull_request:
workflow_dispatch:

jobs:
build-push-docs:
name: Build and Push Zane docs dev images
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache pnpm dependencies
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.OS }}-pnpm-cache-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-pnpm-cache-
- name: Build docs with node
run: |
npm install -g pnpm@8
pnpm install --frozen-lockfile
FORCE_COLOR=true pnpm run build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/zane-ops/docs:pr-${{ github.event.pull_request.number }},ghcr.io/zane-ops/docs:${{ github.sha }}
cache-from: |
type=registry,ref=ghcr.io/zane-ops/docs:pr-${{ github.event.pull_request.number }}
type=registry,ref=ghcr.io/zane-ops/docs:latest
cache-to: type=inline
deploy:
runs-on: ubuntu-latest
name: Deploy
needs: build-push-docs
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get commit message
id: get-commit
run: echo "commit_message=$(git log -1 --pretty=format:%s)" >> $GITHUB_OUTPUT

- name: Bypass Cloudflare for GitHub Action
uses: xiaotianxt/bypass-cloudflare-for-github-action@v1.1.1
- uses: oven-sh/setup-bun@v2
with:
cf_zone_id: ${{ secrets.CF_ZONE_ID }}
cf_api_token: ${{ secrets.CF_API_TOKEN }}
- name: Deploy to ZaneOps
bun-version: latest

- name: Install packages and Deploy to zaneops
shell: bash
run: |
curl -f -o /dev/null --fail \
-H "CF-Access-Client-Id: ${{ secrets.CF_CLIENT_ID }}" \
-H "CF-Access-Client-Secret: ${{ secrets.CF_CLIENT_SECRET }}" \
-X PUT ${{ secrets.STAGING_DEPLOY_WEBHOOK_URL }} \
--data '{
"commit_message": "${{ steps.get-commit.outputs.commit_message }}",
"new_image": "ghcr.io/zane-ops/docs:${{ github.sha }}"
}'
cd scripts
bun install
bun run deploy-pr.ts
env:
CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }}
CF_CLIENT_SECRET: ${{ secrets.CF_CLIENT_SECRET }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BRANCH_NAME: ${{ github.head_ref }}
ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }}
ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }}

- name: Read service URL
id: read_url
run: |
url=$(cat ./scripts/service-url)
echo "url=$url" >> $GITHUB_OUTPUT

- name: Comment on PR
uses: unsplash/comment-on-pr@v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.COMMENT_PAT }}
with:
msg: 🚀 **PR Preview URL:** https://${{ steps.read_url.outputs.url }}
check_for_duplicate_msg: true
31 changes: 31 additions & 0 deletions .github/workflows/close-pr-env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Close PR environment (DEV)
on:
pull_request:
types: [closed]
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Checkout
uses: actions/checkout@v4

- uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Close PR
shell: bash
run: |
cd scripts
bun install
bun run close-pr.ts
env:
CF_CLIENT_ID: ${{ secrets.CF_CLIENT_ID }}
CF_CLIENT_SECRET: ${{ secrets.CF_CLIENT_SECRET }}
PR_NUMBER: ${{ github.event.pull_request.number }}
ZANE_USERNAME: ${{ secrets.ZANE_USERNAME }}
ZANE_PASSWORD: ${{ secrets.ZANE_PASSWORD }}

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev --port 3000 --host",
"dev": "astro dev --port ${PORT:-3000} --host",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
Expand Down
175 changes: 175 additions & 0 deletions scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Caches

.cache

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store
15 changes: 15 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# scripts

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run index.ts
```

This project was created using `bun init` in bun v1.1.45. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
Binary file added scripts/bun.lockb
Binary file not shown.
Loading
Loading