trigger push #2
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: 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' |