diff --git a/.github/workflows/push-examples.yaml b/.github/workflows/push-examples.yaml new file mode 100644 index 00000000..d9d287fd --- /dev/null +++ b/.github/workflows/push-examples.yaml @@ -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/bunnycdn-storage-deploy@v2.2.5 + 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' diff --git a/.github/workflows/push-site.yaml b/.github/workflows/push-site.yaml new file mode 100644 index 00000000..80d1d527 --- /dev/null +++ b/.github/workflows/push-site.yaml @@ -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/bunnycdn-storage-deploy@v2.2.5 + 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' diff --git a/packages/nuekit/src/create.js b/packages/nuekit/src/create.js index 3b3463f5..b58eff6a 100644 --- a/packages/nuekit/src/create.js +++ b/packages/nuekit/src/create.js @@ -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