Update version to 0.8.1 in package.json #316
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: Docker image build and publish | |
| on: | |
| push: | |
| branches: [dev] | |
| pull_request: | |
| branches: [dev] | |
| workflow_dispatch: | |
| inputs: | |
| enable_ecr_workflow: | |
| description: 'Enable ECR workflow' | |
| type: boolean | |
| default: false | |
| required: true | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| # Only assign environment for push events to main/dev (not for PRs) | |
| environment: ${{ github.event_name != 'pull_request' && (github.ref_name == 'main' && 'production' || 'development') || '' }} | |
| permissions: | |
| id-token: write | |
| contents: read | |
| outputs: | |
| image_tag: ${{ steps.set-outputs.outputs.image_tag }} | |
| full_image: ${{ steps.set-outputs.outputs.full_image }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ vars.AWS_IAM_ROLE_ARN }} | |
| aws-region: ${{ vars.AWS_REGION }} | |
| audience: sts.amazonaws.com | |
| role-session-name: GitHubActions | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| with: | |
| registries: ${{ vars.AWS_ACCOUNT_ID }} | |
| # Build only (no push) for all PRs | |
| - name: Build (test only) | |
| if: github.event_name == 'pull_request' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: false | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # Build and push only for direct pushes to main/dev | |
| - name: Build and push | |
| id: build-publish | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY_NAME }}:${{ github.sha }} | |
| ${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY_NAME }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Set output values | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| id: set-outputs | |
| run: | | |
| echo "image_tag=${{ github.sha }}" >> $GITHUB_OUTPUT | |
| echo "full_image=${{ steps.login-ecr.outputs.registry }}/${{ vars.ECR_REPOSITORY_NAME }}:${{ github.sha }}" >> $GITHUB_OUTPUT | |
| - name: Force new deployment of ECS service | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| aws ecs update-service \ | |
| --cluster ${{ vars.ECS_CLUSTER }} \ | |
| --service ${{ vars.ECS_SERVICE }} \ | |
| --force-new-deployment \ | |
| --region ${{ vars.AWS_REGION }} | |
| - name: Wait for service stability | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| run: | | |
| aws ecs wait services-stable \ | |
| --cluster ${{ vars.ECS_CLUSTER }} \ | |
| --services ${{ vars.ECS_SERVICE }} \ | |
| --region ${{ vars.AWS_REGION }} |