this is my yml file below. However code still deploying success on AWS even if my unit test fails on git actions. Please help! I don't understand what triggering the deployment. What should I do?
This is the deploy.yml inside git->workflow
name: CI/CD Pipeline
on:
push:
branches: [ master ]
jobs:
continuous-integration:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install PHP and dependencies
run: sudo apt-get update && sudo apt-get install php php-mbstring php-xml
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SSH_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SSH_PRIVATE_KEY }}
aws-region: us-east-1
- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: vendor/bin/phpunit
continuous-deployment:
runs-on: ubuntu-latest
needs: [continuous-integration]
if: github.ref == 'refs/heads/master'
steps:
# Step 1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.SSH_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SSH_PRIVATE_KEY }}
aws-region: us-east-1
# Step 2
- name: Create CodeDeploy Deployment
id: deploy
run: |
aws deploy create-deployment \
--application-name application-name \
--deployment-group-name AppDeploymentGroupName \
--deployment-config-name CodeDeployDefault.OneAtATime \
--github-location repository=${{ github.repository }},commitId=${{ github.sha }}
This is appspec.yml
:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/test.jitume
hooks:
AfterInstall:
- location: ./scripts/after-install.sh
runas: ubuntu
#BeforeInstall
#AfterInstall
file_exists_behavior: OVERWRITE