ποΈ simplify query parameter from b10cks_ts to ts #16
Workflow file for this run
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
| name: Deploy to AWS ECS | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]+.[0-9]+.[0-9]+-*' | |
| env: | |
| AWS_REGION: eu-west-1 | |
| ECR_REGISTRY: 525984396332.dkr.ecr.eu-west-1.amazonaws.com | |
| ECR_REPOSITORY: b10cks/cms | |
| ECS_CLUSTER: nb-clients01 | |
| ECS_SERVICE: b10cks-cms | |
| ECS_TASK_DEFINITION: b10cks-cms | |
| PHP_VERSION: '8.4' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ env.PHP_VERSION }} | |
| extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, redis | |
| tools: composer:v2 | |
| - name: Install production Composer dependencies | |
| run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --no-dev | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build Docker image | |
| env: | |
| IMAGE_TAG: master-${{ steps.version.outputs.version }} | |
| run: | | |
| docker build \ | |
| --build-arg APP_VERSION=${{ steps.version.outputs.version }} \ | |
| --cache-from ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:cache \ | |
| --build-arg BUILDKIT_INLINE_CACHE=1 \ | |
| -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG \ | |
| -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:cache \ | |
| . | |
| - name: Push Docker image to ECR | |
| env: | |
| IMAGE_TAG: master-${{ steps.version.outputs.version }} | |
| run: | | |
| docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:$IMAGE_TAG | |
| docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:cache | |
| - name: Download current task definition | |
| run: | | |
| aws ecs describe-task-definition \ | |
| --task-definition ${{ env.ECS_TASK_DEFINITION }} \ | |
| --query taskDefinition > task-definition.json | |
| - name: Update task definition with new image | |
| id: task-def | |
| uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
| with: | |
| task-definition: task-definition.json | |
| container-name: ${{ env.ECS_TASK_DEFINITION }} | |
| image: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:master-${{ steps.version.outputs.version }} | |
| - name: Deploy to Amazon ECS service | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
| with: | |
| task-definition: ${{ steps.task-def.outputs.task-definition }} | |
| service: ${{ env.ECS_SERVICE }} | |
| cluster: ${{ env.ECS_CLUSTER }} | |
| wait-for-service-stability: false | |
| - name: Post deployment notifications | |
| if: always() | |
| run: | | |
| if [ ${{ job.status }} == 'success' ]; then | |
| echo "β Deployment successful for version ${{ steps.version.outputs.version }}" | |
| else | |
| echo "β Deployment failed for version ${{ steps.version.outputs.version }}" | |
| fi |