├── .github └── workflows │ ├── php.yml │ ├── azure-webapps-php.yml │ └── index.php └── index.php /.github/workflows/php.yml: -------------------------------------------------------------------------------- 1 | name: PHP Composer 2 | 3 | on: 4 | push: 5 | branches: [ main ] 6 | pull_request: 7 | branches: [ main ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v3 19 | 20 | - name: Validate composer.json and composer.lock 21 | run: composer validate --strict 22 | 23 | - name: Cache Composer packages 24 | id: composer-cache 25 | uses: actions/cache@v3 26 | with: 27 | path: vendor 28 | key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} 29 | restore-keys: | 30 | ${{ runner.os }}-php- 31 | 32 | - name: Install dependencies 33 | run: composer install --prefer-dist --no-progress 34 | 35 | # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" 36 | # Docs: https://getcomposer.org/doc/articles/scripts.md 37 | 38 | # - name: Run test suite 39 | # run: composer run-script test 40 | -------------------------------------------------------------------------------- /.github/workflows/azure-webapps-php.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build and push a PHP application to an Azure Web App when a commit is pushed to your default branch. 2 | # 3 | # This workflow assumes you have already created the target Azure App Service web app. 4 | # For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-php?pivots=platform-linux 5 | # 6 | # To configure this workflow: 7 | # 8 | # 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal. 9 | # For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials 10 | # 11 | # 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret. 12 | # For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret 13 | # 14 | # 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the AZURE_WEBAPP_PACKAGE_PATH and PHP_VERSION environment variables below. 15 | # 16 | # For more information on GitHub Actions for Azure: https://github.com/Azure/Actions 17 | # For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy 18 | # For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples 19 | 20 | name: Build and deploy PHP app to Azure Web App 21 | 22 | on: 23 | push: 24 | branches: 25 | - main 26 | workflow_dispatch: 27 | 28 | env: 29 | AZURE_WEBAPP_NAME: your-app-name # set this to your application's name 30 | AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root 31 | PHP_VERSION: '8.x' # set this to the PHP version to use 32 | 33 | permissions: 34 | contents: read 35 | 36 | jobs: 37 | build: 38 | runs-on: ubuntu-latest 39 | 40 | steps: 41 | - uses: actions/checkout@v3 42 | 43 | - name: Setup PHP 44 | uses: shivammathur/setup-php@7c0b4c8c8ebed23eca9ec2802474895d105b11bc 45 | with: 46 | php-version: ${{ env.PHP_VERSION }} 47 | 48 | - name: Check if composer.json exists 49 | id: check_files 50 | uses: andstor/file-existence-action@87d74d4732ddb824259d80c8a508c0124bf1c673 51 | with: 52 | files: 'composer.json' 53 | 54 | - name: Get Composer Cache Directory 55 | id: composer-cache 56 | if: steps.check_files.outputs.files_exists == 'true' 57 | run: | 58 | echo "::set-output name=dir::$(composer config cache-files-dir)" 59 | 60 | - name: Set up dependency caching for faster installs 61 | uses: actions/cache@v3 62 | if: steps.check_files.outputs.files_exists == 'true' 63 | with: 64 | path: ${{ steps.composer-cache.outputs.dir }} 65 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 66 | restore-keys: | 67 | ${{ runner.os }}-composer- 68 | 69 | - name: Run composer install if composer.json exists 70 | if: steps.check_files.outputs.files_exists == 'true' 71 | run: composer validate --no-check-publish && composer install --prefer-dist --no-progress 72 | 73 | - name: Upload artifact for deployment job 74 | uses: actions/upload-artifact@v3 75 | with: 76 | name: php-app 77 | path: . 78 | 79 | deploy: 80 | permissions: 81 | contents: none 82 | runs-on: ubuntu-latest 83 | needs: build 84 | environment: 85 | name: 'Development' 86 | url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} 87 | 88 | steps: 89 | - name: Download artifact from build job 90 | uses: actions/download-artifact@v3 91 | with: 92 | name: php-app 93 | 94 | - name: 'Deploy to Azure Web App' 95 | id: deploy-to-webapp 96 | uses: azure/webapps-deploy@v2 97 | with: 98 | app-name: ${{ env.AZURE_WEBAPP_NAME }} 99 | publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} 100 | package: . 101 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 133 | -------------------------------------------------------------------------------- /.github/workflows/index.php: -------------------------------------------------------------------------------- 1 | 133 | --------------------------------------------------------------------------------