Merge pull request #24 from inpsyde/AT-716 #188
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: Pre-compile assets | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
tags: | |
- '*' | |
schedule: | |
- cron: '0 0 * * 0' # Run at 00:00 of every sunday | |
jobs: | |
build-assets: | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, 'skip compile') }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: "Setup PHP" | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.0 | |
tools: composer:v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: 16 | |
- name: "Install dependencies" | |
run: composer install --no-interaction --prefer-dist --classmap-authoritative | |
- name: "Extract package hash into env [DEV]" | |
if: ${{ !contains(github.ref, 'refs/tags/') }} | |
run: echo "ASSETS_HASH=$(composer assets-hash)" >> $GITHUB_ENV | |
- name: "Extract tag name into env [PROD]" | |
if: ${{ contains(github.ref, 'refs/tags/') }} | |
run: echo "TAG_NAME=$(echo ${GITHUB_REF#refs/*/})" >> $GITHUB_ENV | |
- name: "Compile assets" | |
run: composer -vvv compile-assets --env=root | |
- name: "Upload assets artifact [DEV]" | |
uses: actions/upload-artifact@v2 | |
if: ${{ !contains(github.ref, 'refs/tags/') }} | |
with: | |
name: assets-${{ env.ASSETS_HASH }} | |
path: assets | |
- name: "Zip assets folder [PROD]" | |
uses: montudor/[email protected] | |
if: ${{ contains(github.ref, 'refs/tags/') }} | |
with: | |
args: zip -qq -r assets-${{ env.TAG_NAME }}.zip assets | |
- name: "Upload release attachment [PROD]" | |
if: ${{ contains(github.ref, 'refs/tags/') }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: assets-${{ env.TAG_NAME }}.zip | |
tag: ${{ github.ref }} | |
overwrite: true | |
body: | | |
# ${{ env.TAG_NAME }} | |
Pre-compiled assets available in `assets-${{ env.TAG_NAME }}.zip`. |