Skip to content

shell: bash

shell: bash #18

Workflow file for this run

name: Setup
on:
push:
branches:
- 'blue-green-deploy'
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
check:
runs-on: ubuntu-latest
outputs:
service_exists: ${{ steps.check-ecs-service.outputs.service_exists }}
steps:
- uses: actions/checkout@v4
- name: Check ECS Service
id: check-ecs-service
uses: ./.github/actions/check_svc
with:
aws_region: ${{ vars.aws_region }}
aws_role: ${{ vars.aws_account_id }}:role/${{ vars.aws_role }}
tfvars_file: "tf/variables.tfvars"
init:
needs: check
if: ${{ needs.check.outputs.service_exists == 'false' }}
uses: ./.github/workflows/build.yml
with:
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}
aws_role: ${{ vars.AWS_ROLE }}
service:
needs:
- check
- init
if: ${{ needs.check.outputs.service_exists == 'false' }}
runs-on: ubuntu-latest
env:
TF_VAR_task_definition_arn: ${{ needs.init.outputs.task_definition_arn }}
outputs:
cluster_name: ${{ steps.set-envs.outputs.CLUSTER_NAME }}
service_name: ${{ steps.set-envs.outputs.SERVICE_NAME }}
lb_listener_arn: ${{ steps.set-envs.outputs.LB_LISTENER_ARN }}
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.aws_region }}
role-to-assume: arn:aws:iam::${{ vars.aws_account_id }}:role/${{ vars.aws_role }}
role-session-name: GitHubActions
- name: Init
shell: bash
run: |
cd tf/service
terraform init
- name: Deploy
shell: bash
id: deploy
run: |
cd tf/service
terraform apply -auto-approve -var-file=${{ github.workspace }}/tf/variables.tfvars
- name: Set env vars
id: set-envs
shell: bash
run: |
cd tf/service
LB_LISTENER_ARN=$(terraform output -raw lb_listener_arn)
echo "LB_LISTENER_ARN=$LB_LISTENER_ARN" >> $GITHUB_OUTPUT
network:
needs:
- check
- service
if: ${{ needs.check.outputs.service_exists == 'false' }}
runs-on: ubuntu-latest
env:
TF_VAR_load_balancer_listener_arn: ${{ needs.service.outputs.lb_listener_arn }}
outputs:
api_invoke_url: ${{ steps.set-envs.outputs.API_INVOKE_URL }}
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.aws_region }}
role-to-assume: arn:aws:iam::${{ vars.aws_account_id }}:role/${{ vars.aws_role }}
role-session-name: GitHubActions
- name: Init
shell: bash
run: |
cd tf/network
terraform init
- name: Deploy
shell: bash
id: deploy
run: |
cd tf/network
terraform apply -auto-approve -var-file=${{ github.workspace }}/tf/variables.tfvars
- name: Set env vars
id: set-envs
shell: bash
run: |
cd tf/network
API_INVOKE_URL=$(terraform output -raw api_invoke_url)
echo "API_INVOKE_URL=$API_INVOKE_URL" >> $GITHUB_OUTPUT