Skip to content

Commit

Permalink
Merge pull request #410 from nobkd/feat-action/web-publish
Browse files Browse the repository at this point in the history
feat(action): site + example publish
  • Loading branch information
nobkd authored Jan 20, 2025
2 parents c6cf1a8 + 38a3cfd commit 5c8ff9a
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 1 deletion.
70 changes: 70 additions & 0 deletions .github/workflows/push-examples.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Push examples to web server

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

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 }}/'

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 }}"

# subsitutes non-alphanumeric characters with _
- name: Build secret variable names
run: |
mdir="${{ matrix.dir }}"
name="${mdir//[^[:alnum:]]/_}"
echo "$name"
echo "storage_name=STORAGE_NAME_$name" >> $GITHUB_ENV
echo "storage_pass=STORAGE_PASS_$name" >> $GITHUB_ENV
echo "pull_id=PULL_ID_$name" >> $GITHUB_ENV
# 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] }}'
storagePassword: '${{ secrets[env.storage_pass] }}'
pullZoneId: '${{ secrets[env.pull_id] }}'
accessKey: '${{ secrets.BUNNY_API_KEY }}'
upload: 'true'
remove: 'false'
purgePullZone: 'true'
37 changes: 37 additions & 0 deletions .github/workflows/push-site.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Push site to web server

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

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

env:
dir: 'packages/nuejs.org/'

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_PASS_site }}'
pullZoneId: '${{ secrets.PULL_ID_site }}'
accessKey: '${{ secrets.BUNNY_API_KEY }}'
upload: 'true'
remove: 'false'
purgePullZone: 'true'
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

0 comments on commit 5c8ff9a

Please sign in to comment.