Skip to content

update cakephp5 workflow #8

update cakephp5 workflow

update cakephp5 workflow #8

Workflow file for this run

# https://book.cakephp.org/5/en/installation.html
name: PHP CakePHP5
on:
push:
branches: [ main ]
paths:
- 'php/cakephp5/**'
workflow_dispatch:
env:
PHP_VERSION: '8.2.x'
WORKING_DIRECTORY: php/cakephp5
PACKAGE_NAME: php-app
ARCHIVE_NAME: cakephp5.zip
permissions:
id-token: write
contents: read
jobs:
build-cakephp5:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@7c0b4c8c8ebed23eca9ec2802474895d105b11bc
with:
php-version: ${{ env.PHP_VERSION }}
- name: Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@87d74d4732ddb824259d80c8a508c0124bf1c673
with:
files: '${{ env.WORKING_DIRECTORY }}/composer.json'
- name: Get Composer Cache Directory
id: composer-cache
if: steps.check_files.outputs.files_exists == 'true'
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Set up dependency caching for faster installs
uses: actions/cache@v2
if: steps.check_files.outputs.files_exists == 'true'
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Run composer install if composer.json exists
if: steps.check_files.outputs.files_exists == 'true'
run: composer validate --no-check-publish && composer install --prefer-dist --no-progress
- name: Set permissions
run: |
chmod -R 777 tmp \
&& chmod -R 777 logs \
&& ls -al
- name: Install zip
uses: montudor/action-zip@v1
- name: Zip output
run: zip -qq -r ${{ env.ARCHIVE_NAME }} .
working-directory: ${{ env.WORKING_DIRECTORY }}
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.WORKING_DIRECTORY }}/${{ env.ARCHIVE_NAME }}
deploy-cakephp5:
runs-on: ubuntu-latest
needs: build-cakephp5
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: ${{ env.PACKAGE_NAME }}
- name: Az CLI Login
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ secrets.AZURE_WEBAPP_NAME }}
slot-name: 'Production'
package: ${{ env.ARCHIVE_NAME }}
- name: Az CLI Logout
run: az logout