feat(full setup): Use castor to setup in local and on Clever Cloud #1
Workflow file for this run
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: Pipeline | |
on: | |
push: | |
branches: [ develop, master ] | |
pull_request: | |
jobs: | |
tests: | |
name: Tests (PHP ${{ matrix.php }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
php: [ '8.1' ] | |
env: | |
COMPOSER_ARGS: --prefer-dist | |
DOCKER_INTERACTIVE_ARGS: -t | |
NODE_AUTH_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php }} | |
ini-values: date.timezone=UTC | |
tools: symfony-cli | |
- name: Set project php-version | |
run: | | |
echo "${{ matrix.php }}" > .php-version | |
- name: Install WKHTMLTOPDF | |
run: | | |
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb | |
sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb | |
- name: Get composer cache directory | |
id: composer-cache | |
working-directory: apps/sylius | |
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Composer Github Auth | |
run: composer config -g github-oauth.github.com ${{ github.token }} | |
- name: Cache node modules | |
id: cache-yarn | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: | | |
**/node_modules | |
key: ${{ runner.os }}-node-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-build-${{ env.cache-name }}- | |
${{ runner.os }}-node-build- | |
- run: make install | |
- run: make test.composer | |
- run: make test.phpcs | |
- run: make test.phpunit | |
- run: make test.phpstan | |
- run: make test.phpspec | |
- run: make test.phpmd | |
- run: make test.yaml | |
- run: make test.twig | |
- run: make test.schema | |
- run: make test.container | |
- name: Prepare deployment artifact | |
if: ${{ github.ref_name == vars.PRODUCTION_BRANCH }} | |
run: | | |
rm -rf apps/sylius/var/{cache,log} apps/sylius/public/media | |
tar --exclude-vcs --exclude node_modules -cvzf ~/application.tgz ./apps/sylius | |
- name: Upload deployment artifact | |
if: ${{ github.ref_name == vars.PRODUCTION_BRANCH }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: application | |
path: ~/application.tgz | |
production_deployment: | |
name: Deploy to production | |
if: ${{ github.ref_name == vars.PRODUCTION_BRANCH }} | |
needs: tests | |
runs-on: ubuntu-latest | |
concurrency: | |
group: production | |
cancel-in-progress: true | |
environment: | |
name: production | |
url: ${{ vars.PRODUCTION_URL }} | |
env: | |
CLEVER_TOKEN: ${{ secrets.CLEVER_TOKEN }} | |
CLEVER_SECRET: ${{ secrets.CLEVER_SECRET }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install clever-tools | |
run: | | |
npm install -g clever-tools | |
clever login --token $CLEVER_TOKEN --secret $CLEVER_SECRET | |
- name: Prepare deployment | |
run: | | |
mkdir -p ~/deployment | |
cp .clever.json ~/deployment/ | |
cp -rv clevercloud ~/deployment/ | |
cd ~/deployment | |
git config --global user.email "madamebiz@monsieurbiz.com" | |
git config --global user.name "Madame Biz" | |
git init | |
- name: Download deployment artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: application | |
path: ~/deployment/ | |
- name: Deploy | |
run: | | |
cd ~/deployment | |
git add -A | |
git commit -m "Deploy" | |
clever deploy -a prod --force |