Last active
June 6, 2024 13:52
-
-
Save leecolarelli/e83a50eaba42647d04a2c32ccaf35007 to your computer and use it in GitHub Desktop.
My GitHub deployment workflows
This file contains hidden or 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
| # Test and deploy pushes to the development branch. | |
| name: Test and deploy the development branch | |
| on: | |
| push: | |
| branches: | |
| - development | |
| pull_request: | |
| branches: | |
| - development | |
| jobs: | |
| deploy-development: | |
| runs-on: ubuntu-latest | |
| # Set-up database | |
| services: | |
| mysql: | |
| image: mysql:8.0.33 | |
| env: | |
| MYSQL_DATABASE: tgb_bigcommerce_testing | |
| MYSQL_ALLOW_EMPTY_PASSWORD: true | |
| ports: | |
| - '3306:3306' | |
| options: >- | |
| --health-cmd "mysqladmin ping -ppass" | |
| --health-interval 10s | |
| --health-start-period 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| # Check out repository | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| # Set up PHP and tools with shivammathur/setup-php | |
| - name: Setup PHP and tools | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| coverage: xdebug | |
| # Set up problem matchers for PHP output | |
| - name: Setup problem matchers for PHP | |
| run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" | |
| # Set up problem matchers for PHPUnit output | |
| - name: Setup problem matchers for PHPUnit | |
| run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
| # Cache composer packages | |
| - name: Cache Composer packages | |
| id: composer-cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php- | |
| # Install composer dependencies | |
| - name: Install composer dependencies | |
| run: composer install --no-interaction --no-progress --optimize-autoloader --prefer-dist | |
| # Run composer checks | |
| - name: Run composer checks | |
| run: composer run-script check | |
| # Cache node modules | |
| - name: Cache node modules | |
| id: cache-npm | |
| uses: actions/cache@v3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| # npm cache files are stored in `~/.npm` on Linux/macOS | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| # List node modules state | |
| - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
| name: List the state of node modules | |
| continue-on-error: true | |
| run: npm list | |
| # Install node dependencies | |
| - name: Install node dependencies | |
| run: npm ci | |
| # Run js checks | |
| - name: Run js checks | |
| run: npm run check | |
| # Require vapor cli | |
| - name: Require Vapor CLI | |
| run: composer global require laravel/vapor-cli | |
| # Deploy to Laravel Vapor | |
| - name: Deploy development environment | |
| run: vapor deploy development | |
| env: | |
| VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} |
This file contains hidden or 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
| # Test and deploy pushes to the production (main) branch. | |
| name: Test and deploy the production (main) branch | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| deploy-production: | |
| runs-on: ubuntu-latest | |
| # Set-up database | |
| services: | |
| mysql: | |
| image: mysql:8.0.33 | |
| env: | |
| MYSQL_DATABASE: tgb_bigcommerce_testing | |
| MYSQL_ALLOW_EMPTY_PASSWORD: true | |
| ports: | |
| - '3306:3306' | |
| options: >- | |
| --health-cmd "mysqladmin ping -ppass" | |
| --health-interval 10s | |
| --health-start-period 10s | |
| --health-timeout 5s | |
| --health-retries 10 | |
| permissions: | |
| contents: write | |
| steps: | |
| # Check out repository | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| # Set up PHP and tools with shivammathur/setup-php | |
| - name: Setup PHP and tools | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.3' | |
| coverage: xdebug | |
| # Set up problem matchers for PHP output | |
| - name: Setup problem matchers for PHP | |
| run: echo "::add-matcher::${{ runner.tool_cache }}/php.json" | |
| # Set up problem matchers for PHPUnit output | |
| - name: Setup problem matchers for PHPUnit | |
| run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | |
| # Cache composer packages | |
| - name: Cache Composer packages | |
| id: composer-cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: vendor | |
| key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php- | |
| # Install composer dependencies | |
| - name: Install composer dependencies | |
| run: composer install --no-interaction --no-progress --optimize-autoloader --prefer-dist | |
| # Run composer checks | |
| - name: Run composer checks | |
| run: composer run-script check | |
| # Cache node modules | |
| - name: Cache node modules | |
| id: cache-npm | |
| uses: actions/cache@v3 | |
| env: | |
| cache-name: cache-node-modules | |
| with: | |
| # npm cache files are stored in `~/.npm` on Linux/macOS | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| # List node modules state | |
| - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
| name: List the state of node modules | |
| continue-on-error: true | |
| run: npm list | |
| # Install node dependencies | |
| - name: Install node dependencies | |
| run: npm ci | |
| # Run js checks | |
| - name: Run js checks | |
| run: npm run check | |
| # Require vapor cli | |
| - name: Require Vapor CLI | |
| run: composer global require laravel/vapor-cli | |
| # Deploy to Laravel Vapor | |
| - name: Deploy production environment | |
| run: vapor deploy production | |
| env: | |
| VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to use mysql db for testing