|
| 1 | +name: Push examples to web server |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - packages/examples/** |
| 9 | + |
| 10 | +jobs: |
| 11 | + examples: |
| 12 | + if: ${{ github.repository_owner == 'nuejs' }} |
| 13 | + |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + dir: # dirs in "examples" to run build & push process for |
| 17 | + - simple-blog |
| 18 | + |
| 19 | + env: |
| 20 | + dir: 'packages/examples/${{ matrix.dir }}/' |
| 21 | + |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + with: # get entries to check for change in dir |
| 27 | + fetch-depth: 2 |
| 28 | + |
| 29 | + - name: Check dir changes |
| 30 | + run: git diff --name-only HEAD^ HEAD | grep -q "^${{ env.dir }}" |
| 31 | + |
| 32 | + # subsitutes non-alphanumeric characters with _ |
| 33 | + - name: Build secret variable names |
| 34 | + run: | |
| 35 | + mdir="${{ matrix.dir }}" |
| 36 | + name="${mdir//[^[:alnum:]]/_}" |
| 37 | + echo "$name" |
| 38 | + echo "storage_name=STORAGE_NAME_$name" >> $GITHUB_ENV |
| 39 | + echo "storage_pass=STORAGE_PASS_$name" >> $GITHUB_ENV |
| 40 | + echo "pull_id=PULL_ID_$name" >> $GITHUB_ENV |
| 41 | +
|
| 42 | + # creates archive of dir, removes img dirs, moves content to subdir "source" |
| 43 | + - name: Create test archive |
| 44 | + run: tar -C "${{ env.dir }}" --exclude "*/img" --transform "s/^\.\//source\//" -cf "${{ env.dir }}test.tar.gz" . |
| 45 | + if: ${{ matrix.dir == 'simple-blog' }} |
| 46 | + |
| 47 | + # creates archive of dir, moves content to subdir "source" |
| 48 | + - name: Create source archive |
| 49 | + run: git archive --prefix "source/" -o "${{ env.dir }}source.tar.gz" "HEAD:${{ env.dir }}" |
| 50 | + |
| 51 | + # Copy source archive, to allow old source path on web server. Step should get removed after new release and a bit of time |
| 52 | + - name: Duplicate source archive |
| 53 | + run: cp "${{ env.dir }}source.tar.gz" "${{ env.dir }}${{ matrix.dir }}.tar.gz" |
| 54 | + |
| 55 | + - name: Nue build |
| 56 | + uses: ./.github/workflows/repo/build-page |
| 57 | + with: |
| 58 | + root: ${{ env.dir }} |
| 59 | + |
| 60 | + - name: BunnyCDN storage deployer |
| 61 | + uses: ayeressian/bunnycdn-storage-deploy@v2.2.5 |
| 62 | + with: |
| 63 | + source: '${{ env.dir }}.dist/prod' |
| 64 | + storageZoneName: '${{ secrets[env.storage_name] }}' |
| 65 | + storagePassword: '${{ secrets[env.storage_pass] }}' |
| 66 | + pullZoneId: '${{ secrets[env.pull_id] }}' |
| 67 | + accessKey: '${{ secrets.BUNNY_API_KEY }}' |
| 68 | + upload: 'true' |
| 69 | + remove: 'false' |
| 70 | + purgePullZone: 'true' |
0 commit comments