Skip to content

PHP Simple

PHP Simple #11

Workflow file for this run

# https://learn.microsoft.com/ja-jp/azure/app-service/configure-language-php?pivots=platform-linux
name: PHP Simple
on:
push:
branches: [ main ]
paths:
- 'php/simple/**'
workflow_dispatch:
env:
PHP_VERSION: '8.2'
WORKING_DIRECTORY: php/simple
permissions:
id-token: write
contents: read
jobs:
build-php:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
- name: Check if composer.json exists
id: check_files
uses: andstor/file-existence-action@v1
with:
files: '${{ env.WORKING_DIRECTORY }}/composer.json'
- 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: Zip artifact for deployment
run: zip release.zip ./* -r
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: php-app
path: release.zip
deploy-php:
runs-on: ubuntu-latest
needs: build-php
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: php-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Az CLI Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# - name: Azure App Service Settings
# uses: Azure/appservice-settings@v1
# with:
# app-name: ${{ vars.AZURE_WEBAPP_NAME }}-php
# slot-name: 'Production'
# app-settings-json: '[{"name":"SCM_DO_BUILD_DURING_DEPLOYMENT","value":"1","slotSetting":false}]'
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}-php
slot-name: 'Production'
package: .
- name: Az CLI Logout
run: az logout