diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 16a5262..bbea462 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,10 +1,11 @@ -name: Deploy +name: Deploy to Vapor on: push: branches: - main - develop + - releases/** workflow_dispatch: jobs: @@ -13,30 +14,32 @@ jobs: uses: lostlink/dotenv/.github/workflows/tlint.yml@main secrets: COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} + linters-phpcs: name: Linters uses: lostlink/dotenv/.github/workflows/phpcs.yml@main secrets: COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} + linters-phpstan: name: Linters uses: lostlink/dotenv/.github/workflows/phpstan.yml@main secrets: COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }} + test: name: Test uses: lostlink/dotenv/.github/workflows/test.yml@main secrets: COMPOSER_AUTH_JSON: ${{ secrets.COMPOSER_AUTH_JSON }} + deploy: name: Deploy to Vapor runs-on: ubuntu-latest needs: [linters-tlint,linters-phpcs,linters-phpstan,test] - concurrency: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - ${{ matrix.region }} - environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - env: - APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} + concurrency: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} - ${{ matrix.region }} + environment: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} strategy: fail-fast: false @@ -52,6 +55,18 @@ jobs: with: lfs: true + - name: Set Environment - Production + if: contains(github.ref, 'refs/heads/releases/') + run: echo "APP_ENV=production" >> $GITHUB_ENV + + - name: Set Environment - Staging + if: contains(github.ref, 'refs/heads/main') + run: echo "APP_ENV=staging" >> $GITHUB_ENV + + - name: Set Environment - Develop + if: contains(github.ref, 'refs/heads/develop') || contains(github.ref, 'refs/heads/feature') || contains(github.ref, 'refs/heads/hotfix') + run: echo "APP_ENV=develop" >> $GITHUB_ENV + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml index 63a2795..2fadf1f 100644 --- a/.github/workflows/phpcs.yml +++ b/.github/workflows/phpcs.yml @@ -3,8 +3,8 @@ name: Linters - PHPCS on: push: branches: - - feature/* - - hotfix/* + - hotfix/** + - feature/** workflow_call: secrets: COMPOSER_AUTH_JSON: @@ -14,14 +14,24 @@ jobs: phpcs: name: PHPCS runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - env: - APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} + environment: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} steps: - name: Check out code uses: actions/checkout@v2 + - name: Set Environment - Production + if: contains(github.ref, 'refs/heads/releases/') + run: echo "APP_ENV=production" >> $GITHUB_ENV + + - name: Set Environment - Staging + if: contains(github.ref, 'refs/heads/main') + run: echo "APP_ENV=staging" >> $GITHUB_ENV + + - name: Set Environment - Develop + if: contains(github.ref, 'refs/heads/develop') || contains(github.ref, 'refs/heads/feature') || contains(github.ref, 'refs/heads/hotfix') + run: echo "APP_ENV=develop" >> $GITHUB_ENV + - name: Cache dependencies uses: actions/cache@v2 with: @@ -41,8 +51,15 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress --no-scripts --ignore-platform-reqs + - name: Remove auth.json file + run: rm -f $GITHUB_WORKSPACE/auth.json + - name: PHPCS lint run: vendor/bin/duster phpcs - - name: Remove auth.json file - run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Upload artifacts + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Logs + path: ./storage/logs diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 7819826..31ab068 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -3,8 +3,8 @@ name: Linters - PHPStan on: push: branches: - - feature/* - - hotfix/* + - hotfix/** + - feature/** workflow_call: secrets: COMPOSER_AUTH_JSON: @@ -16,14 +16,24 @@ jobs: phpstan: name: PHPStan runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - env: - APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} + environment: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} steps: - name: Check out code uses: actions/checkout@v2 + - name: Set Environment - Production + if: contains(github.ref, 'refs/heads/releases/') + run: echo "APP_ENV=production" >> $GITHUB_ENV + + - name: Set Environment - Staging + if: contains(github.ref, 'refs/heads/main') + run: echo "APP_ENV=staging" >> $GITHUB_ENV + + - name: Set Environment - Develop + if: contains(github.ref, 'refs/heads/develop') || contains(github.ref, 'refs/heads/feature') || contains(github.ref, 'refs/heads/hotfix') + run: echo "APP_ENV=develop" >> $GITHUB_ENV + - name: Cache dependencies uses: actions/cache@v2 with: @@ -43,6 +53,9 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress --no-scripts --ignore-platform-reqs + - name: Remove auth.json file + run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Set VaporFile from Region run: | ./vapor-switch.sh --region us-east-1 --force @@ -57,5 +70,9 @@ jobs: - name: PHPStan Analyze run: vendor/bin/phpstan analyze - - name: Remove auth.json file - run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Upload artifacts + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Logs + path: ./storage/logs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4e257a9..e806ed3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,8 +3,8 @@ name: Test on: push: branches: - - feature/* - - hotfix/* + - hotfix/** + - feature/** workflow_call: secrets: COMPOSER_AUTH_JSON: @@ -14,14 +14,24 @@ jobs: test: name: Test runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - env: - APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} + environment: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} steps: - name: Check out code uses: actions/checkout@v2 + - name: Set Environment - Production + if: contains(github.ref, 'refs/heads/releases/') + run: echo "APP_ENV=production" >> $GITHUB_ENV + + - name: Set Environment - Staging + if: contains(github.ref, 'refs/heads/main') + run: echo "APP_ENV=staging" >> $GITHUB_ENV + + - name: Set Environment - Develop + if: contains(github.ref, 'refs/heads/develop') || contains(github.ref, 'refs/heads/feature') || contains(github.ref, 'refs/heads/hotfix') + run: echo "APP_ENV=develop" >> $GITHUB_ENV + - name: Setup Node uses: actions/setup-node@v2 with: @@ -50,6 +60,9 @@ jobs: - name: Install Composer dependencies run: composer install --prefer-dist --no-interaction --no-progress --no-scripts + - name: Remove auth.json file + run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Copy testing environment config file run: php -r "file_exists('.env') || copy('.env.testing', '.env');" @@ -73,6 +86,3 @@ jobs: with: name: Logs path: ./storage/logs - - - name: Remove auth.json file - run: rm -f $GITHUB_WORKSPACE/auth.json diff --git a/.github/workflows/tlint.yml b/.github/workflows/tlint.yml index 92174ae..185fa8b 100644 --- a/.github/workflows/tlint.yml +++ b/.github/workflows/tlint.yml @@ -3,8 +3,8 @@ name: Linters - TLint on: push: branches: - - feature/* - - hotfix/* + - hotfix/** + - feature/** workflow_call: secrets: COMPOSER_AUTH_JSON: @@ -14,14 +14,24 @@ jobs: tlint: name: TLint runs-on: ubuntu-latest - environment: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} - env: - APP_ENV: ${{ github.ref == 'refs/heads/main' && 'production' || 'develop' }} + environment: ${{ contains(github.ref, 'refs/heads/releases/') && 'production' || 'develop' }} steps: - name: Check out code uses: actions/checkout@v2 + - name: Set Environment - Production + if: contains(github.ref, 'refs/heads/releases/') + run: echo "APP_ENV=production" >> $GITHUB_ENV + + - name: Set Environment - Staging + if: contains(github.ref, 'refs/heads/main') + run: echo "APP_ENV=staging" >> $GITHUB_ENV + + - name: Set Environment - Develop + if: contains(github.ref, 'refs/heads/develop') || contains(github.ref, 'refs/heads/feature') || contains(github.ref, 'refs/heads/hotfix') + run: echo "APP_ENV=develop" >> $GITHUB_ENV + - name: Cache dependencies uses: actions/cache@v2 with: @@ -41,8 +51,15 @@ jobs: - name: Install dependencies run: composer install --prefer-dist --no-interaction --no-progress --no-scripts --ignore-platform-reqs + - name: Remove auth.json file + run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Tlint Lint run: vendor/bin/duster tlint - - name: Remove auth.json file - run: rm -f $GITHUB_WORKSPACE/auth.json + - name: Upload artifacts + uses: actions/upload-artifact@v2 + if: failure() + with: + name: Logs + path: ./storage/logs