Deploy-staging-ecs #1
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-staging | ||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| custom_tag: | ||
| description: 'Set custom tag for image' | ||
| required: true | ||
| type: string | ||
| environment: | ||
| type: choice | ||
| description: 'The environment to deploy to' | ||
| options: | ||
| - staging | ||
| - production | ||
| required: true | ||
| default: 'staging' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths-ignore: | ||
| - '.github/**' | ||
| - '**.md' | ||
| jobs: | ||
| context: | ||
| name: Setup context | ||
| runs-on: ubuntu-latest | ||
| environment: ${{ inputs.environment }} | ||
| outputs: | ||
| aws_region: ${{ steps.get.outputs.aws_region }} | ||
| aws_ecr_uri: ${{ steps.get.outputs.aws_ecr_uri }} | ||
| aws_ecr_region: ${{ steps.get.outputs.aws_ecr_region }} | ||
| aws_ecr_account_id: ${{ steps.get.outputs.aws_ecr_account_id }} | ||
| aws_ecs_cluster: ${{ steps.get.outputs.aws_ecs_cluster }} | ||
| steps: | ||
| - id: get | ||
| run: | | ||
| echo "aws_region=${{ vars.AWS_REGION }}" >> "$GITHUB_OUTPUT" | ||
| echo "aws_ecr_uri=${{ vars.AWS_ECR_URI }}" >> "$GITHUB_OUTPUT" | ||
| echo "aws_ecr_region=${{ vars.AWS_ECR_REGION }}" >> "$GITHUB_OUTPUT" | ||
| echo "aws_ecr_account_id=${{ vars.AWS_ECR_ACCOUNT_ID }}" >> "$GITHUB_OUTPUT" | ||
| echo "aws_ecs_cluster=${{ vars.AWS_ECS_CLUSTER }}" >> "$GITHUB_OUTPUT" | ||
| build-push-image: | ||
| if: ${{ github.event_name == 'push' }} | ||
| name: Build deploy image and push to registry | ||
| uses: infinum/devops-pipelines/.github/workflows/[email protected] | ||
| needs: context | ||
| with: | ||
| environment: ${{ inputs.environment }} | ||
| cloud: AWS | ||
| tags: ${{ needs.context.outputs.aws_ecr_uri }}:${{ github.sha }} | ||
| aws_ecr_region: ${{ needs.context.outputs.aws_ecr_region }} | ||
| aws_ecr_account_id: ${{ needs.context.outputs.aws_ecr_account_id }} | ||
| target: deploy | ||
| secrets: inherit | ||
| build-push-image-manual: | ||
| if: ${{ github.event_name == 'workflow_dispatch' }} | ||
| name: Run on workflow dispatch | ||
| uses: infinum/devops-pipelines/.github/workflows/[email protected] | ||
| needs: context | ||
| with: | ||
| environment: ${{ inputs.environment }} | ||
| cloud: AWS | ||
| tags: ${{ needs.context.outputs.aws_ecr_uri }}:${{ inputs.custom_tag }} | ||
| aws_ecr_region: ${{ needs.context.outputs.aws_ecr_region }} | ||
| aws_ecr_account_id: ${{ needs.context.outputs.aws_ecr_account_id }} | ||
| secrets: inherit | ||
| deploy-image: | ||
| if: ${{ github.event_name == 'push' }} | ||
| name: Deploy backend | ||
| uses: infinum/devops-pipelines/.github/workflows/[email protected] | ||
|
Check failure on line 75 in .github/workflows/deploy-staging-ecs.yml
|
||
| needs: [context, build-push-image] | ||
| with: | ||
| image_uri: ${{ needs.context.outputs.aws_ecr_uri }}:${{ github.sha }} | ||
| environment: ${{ inputs.environment }} | ||
| aws_region: ${{ needs.context.outputs.aws_region }} | ||
| ecs_cluster: ${{ needs.context.outputs.aws_ecs_cluster }} | ||
| ecs_service: js-react-example | ||
| task_def_path: .aws/ecs/task-definition-app-staging.json | ||
| container_name: js-react-example | ||
| secrets: inherit | ||
| deploy-image-manual: | ||
| if: ${{ github.event_name == 'workflow_dispatch' }} | ||
| name: Deploy backend | ||
| uses: infinum/devops-pipelines/.github/workflows/[email protected] | ||
| needs: [context, build-push-image-manual] | ||
| with: | ||
| image_uri: ${{ needs.context.outputs.aws_ecr_uri }}:${{ inputs.custom_tag }} | ||
| environment: ${{ inputs.environment }} | ||
| aws_region: ${{ needs.context.outputs.aws_region }} | ||
| ecs_cluster: ${{ needs.context.outputs.aws_ecs_cluster }} | ||
| ecs_service: js-react-example | ||
| task_def_path: .aws/ecs/task-definition-app-staging.json | ||
| container_name: js-react-example | ||
| secrets: inherit | ||