Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(action): site + example publish #410

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
65 changes: 65 additions & 0 deletions .github/workflows/push-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Push examples to web server

on:
push:
branches:
- master
paths:
- packages/examples/**

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
examples:
if: ${{ github.repository_owner == 'nuejs' }}

strategy:
matrix:
dir: # dirs in "examples" to run build & push process for
- simple-blog

env:
dir: 'packages/examples/${{ matrix.dir }}/'
archive: 'site.tar.gz'
storage_name_key: 'STORAGE_NAME_${{ matrix.dir }}'
storage_password_key: 'STORAGE_PASSWORD_${{ matrix.dir }}'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with: # get entries to check for change in dir
fetch-depth: 2

- name: Check dir changes
run: git diff --name-only HEAD^ HEAD | grep -q "^${{ env.dir }}"

# creates archive of dir, removes img dirs, moves content to subdir "source"
- name: Create test archive
run: tar -C "${{ env.dir }}" --exclude "*/img" --transform "s/^\.\//source\//" -cf "${{ env.dir }}test.tar.gz" .
if: ${{ matrix.dir == 'simple-blog' }}

# creates archive of dir, moves content to subdir "source"
- name: Create source archive
run: git archive --prefix "source/" -o "${{ env.dir }}source.tar.gz" "HEAD:${{ env.dir }}"

# Copy source archive, to allow old source path on web server. Step should get removed after new release and a bit of time
- name: Duplicate source archive
run: cp "${{ env.dir }}source.tar.gz" "${{ env.dir }}${{ matrix.dir }}.tar.gz"

- name: Nue build
uses: ./.github/workflows/repo/build-page
with:
root: ${{ env.dir }}

- name: BunnyCDN storage deployer
uses: ayeressian/[email protected]
with:
source: '${{ env.dir }}.dist/prod'
storageZoneName: '${{ secrets[env.storage_name_key] }}'
storagePassword: '${{ secrets[env.storage_password_key] }}'
upload: 'true'
remove: 'false'
purgePullZone: 'false'
40 changes: 40 additions & 0 deletions .github/workflows/push-site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Push site to web server

on:
push:
branches:
- master
paths:
- packages/nuejs.org/**

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
site:
if: ${{ github.repository_owner == 'nuejs' }}

env:
dir: 'packages/nuejs.org/'
archive: 'site.tar.gz'

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Nue build
uses: ./.github/workflows/repo/build-page
with:
root: ${{ env.dir }}

- name: BunnyCDN storage deployer
uses: ayeressian/[email protected]
with:
source: '${{ env.dir }}.dist/prod'
storageZoneName: '${{ secrets.STORAGE_NAME_site }}'
storagePassword: '${{ secrets.STORAGE_PASSWORD_site }}'
upload: 'true'
remove: 'false'
purgePullZone: 'false'
2 changes: 1 addition & 1 deletion packages/nuekit/src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function create({ root, name = 'simple-blog', port }) {
// download archive
console.info('Loading template...')
const archive_name = join(root, `${name}-source.tar.gz`)
const archive = await fetch(`https://${name}.nuejs.org/${debug ? 'test' : name}.tar.gz`)
const archive = await fetch(`https://${name}.nuejs.org/${debug ? 'test' : 'source'}.tar.gz`)
await fs.writeFile(archive_name, Buffer.from(await archive.arrayBuffer()))

// uncompress
Expand Down
Loading