Skip to content

chore: add deprecation warnings #1

chore: add deprecation warnings

chore: add deprecation warnings #1

name: [DEPRECATED] Assets compilation

Check failure on line 1 in .github/workflows/build-assets-compilation.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-assets-compilation.yml

Invalid workflow file

You have an error in your yaml syntax
on:
workflow_call:
inputs:
NODE_OPTIONS:
description: Space-separated list of command-line Node options.
type: string
default: ''
required: false
NODE_VERSION:
description: Node version with which the static code analysis is to be executed.
default: 18
required: false
type: string
NPM_REGISTRY_DOMAIN:
description: Domain of the private npm registry.
default: https://npm.pkg.github.com/
required: false
type: string
PACKAGE_MANAGER:
description: Package manager with which the dependencies should be installed (`npm` or `yarn`).
default: 'npm'
required: false
type: string
PHP_VERSION:
description: PHP version with which the assets compilation is to be executed.
default: '8.2'
required: false
type: string
COMPOSER_ARGS:
description: Set of arguments passed to Composer.
default: '--prefer-dist'
required: false
type: string
COMPILE_ASSETS_ARGS:
description: Set of arguments passed to Composer Asset Compiler.
default: '-v --env=root'
required: false
type: string
secrets:
COMPOSER_AUTH_JSON:
description: Authentication for privately hosted packages and repositories as a JSON formatted object.
required: false
NPM_REGISTRY_TOKEN:
description: Authentication for the private npm registry.
required: false
GITHUB_USER_EMAIL:
description: Email address for the GitHub user configuration.
required: false
GITHUB_USER_NAME:
description: Username for the GitHub user configuration.
required: false
GITHUB_USER_SSH_KEY:
description: Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME`.
required: false
ENV_VARS:
description: Additional environment variables as a JSON formatted object.
required: false
jobs:
assets-compilation:
timeout-minutes: 5
runs-on: ubuntu-latest
env:
NODE_CACHE_MODE: ''
steps:
- name: Deprecation warning
run: echo "::warning::This workflow is deprecated and will be removed soon. Use .github/workflows/build-push.yml instead."
- name: PACKAGE_MANAGER deprecation warning
if: ${{ inputs.PACKAGE_MANAGER != '' }}
run: |
if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ]; then
echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please remove it. The workflow already uses npm by default."
else
echo "::warning::The PACKAGE_MANAGER input is deprecated and will be removed soon. Please update your workflow to use npm."
fi
- name: Checkout
uses: actions/checkout@v4
- name: Set up custom environment variables
env:
ENV_VARS: ${{ secrets.ENV_VARS }}
if: ${{ env.ENV_VARS }}
uses: actions/github-script@v7
with:
script: |
JSON
.parse(process.env.ENV_VARS)
.forEach(envVar => core.exportVariable(envVar.name, envVar.value));
- name: Set up SSH
env:
GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }}
if: ${{ env.GITHUB_USER_SSH_KEY != '' }}
uses: webfactory/ssh-agent@v0.9.1
with:
ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }}
- name: Set up Git
env:
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
if: ${{ env.GITHUB_USER_EMAIL != '' && env.GITHUB_USER_NAME != '' }}
run: |
git config --global user.email "${{ env.GITHUB_USER_EMAIL }}"
git config --global user.name "${{ env.GITHUB_USER_NAME }}"
- name: Set up node cache mode
run: |
if [ "${{ inputs.PACKAGE_MANAGER }}" == 'npm' ] && { [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; }; then
echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV
elif [ "${{ inputs.PACKAGE_MANAGER }}" == 'yarn' ] && [ -f "${GITHUB_WORKSPACE}/yarn.lock" ]; then
echo "NODE_CACHE_MODE=yarn" >> $GITHUB_ENV
else
echo "No lock files found or unknown package manager"
fi
- name: Set up node
uses: actions/setup-node@v4
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
with:
node-version: ${{ inputs.NODE_VERSION }}
registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }}
cache: ${{ env.NODE_CACHE_MODE }}
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.PHP_VERSION }}
tools: composer
coverage: none
- name: Install Composer dependencies
uses: ramsey/composer-install@v3
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
with:
composer-options: ${{ inputs.COMPOSER_ARGS }}
- name: Set environment variables [DEV]
if: ${{ !contains(github.ref, 'refs/tags/') }}
run: |
echo "ASSETS_HASH=$(composer assets-hash)" >> $GITHUB_ENV
# We set "development" here to align with webpack's "mode"
# to be used in Composer Asset Compiler as a placeholder variable.
# @link https://webpack.js.org/configuration/mode/
echo "BUILD_ENV=development" >> $GITHUB_ENV
- name: Set environment variables [PROD]
if: ${{ contains(github.ref, 'refs/tags/') }}
run: |
echo "TAG_NAME=$(echo ${GITHUB_REF#refs/*/})" >> $GITHUB_ENV
echo "BUILD_ENV=production" >> $GITHUB_ENV
echo "::notice::The ENCORE_ENV variable is deprecated and will be removed soon. If you use it, please change it to BUILD_ENV."
echo "ENCORE_ENV=production" >> $GITHUB_ENV
- name: Compile assets
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH_JSON }}'
run: composer compile-assets ${{ inputs.COMPILE_ASSETS_ARGS }}
- name: Upload assets artifact [DEV]
uses: actions/upload-artifact@v4
if: ${{ !contains(github.ref, 'refs/tags/') }}
with:
name: assets-${{ env.ASSETS_HASH }}
path: assets
overwrite: true
include-hidden-files: true
- name: Zip assets folder [PROD]
uses: montudor/action-zip@v1
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 }}
# Release description fallback which will not be enforced due "overwrite: false" (default).
body: |
# ${{ env.TAG_NAME }}
Compiled assets available in `assets-${{ env.TAG_NAME }}.zip`.