From 6c602a162d56e697ed730693c74b4f661239762b Mon Sep 17 00:00:00 2001 From: chrispsheehan Date: Mon, 30 Sep 2024 14:27:40 +0100 Subject: [PATCH] service and network deploy --- .github/workflows/setup.yml | 158 ++++++++++++++++++------------------ 1 file changed, 78 insertions(+), 80 deletions(-) diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 0c6a3dd..d60f891 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -75,87 +75,85 @@ jobs: 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 - # 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: 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/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 + - 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 \ No newline at end of file