Skip to content

Commit

Permalink
Pass the vars variable to composite action
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronaldo Macapobre committed Aug 22, 2024
1 parent 0429801 commit 93a6f48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/actions/deploy-to-aws/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ inputs:
environment:
description: The environment to which the image will be deployed.
required: true
aws_account:
description: The AWS Account ID.
required: true
region:
description: The AWS Region of the AWS Account.
required: true
app_name:
description: The application name.
required: true
aws_role_arn:
description: The AWS Role ARN to assume.
required: true

# Image parameters
ghcr_token:
Expand All @@ -23,7 +35,7 @@ inputs:
runs:
using: composite
env:
aws_ecr_repo_url: ${{ vars.AWS_ACCOUNT }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.APP_NAME }}-ecr-repo-${{ inputs.environment }}
aws_ecr_repo_url: ${{ inputs.aws_account }}.dkr.ecr.${{ inputs.region }}.amazonaws.com/${{ inputs.app_name }}-ecr-repo-${{ inputs.environment }}
steps:
- name: Log in to the GHCR
uses: docker/login-action@v2
Expand All @@ -36,14 +48,14 @@ runs:
uses: aws-actions/configure-aws-credentials@v4
with:
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
aws-region: ${{ inputs.region }}
role-to-assume: ${{ inputs.aws_role_arn }}
role-duration-seconds: 1800
role-session-name: ci-deployment

- name: Login to AWS CLI
run: |
aws ecr get-login-password --region ${{ vars.AWS_REGION }} | docker login --username AWS --password-stdin ${{ env.aws_ecr_repo_url }}
aws ecr get-login-password --region ${{ inputs.region }} | docker login --username AWS --password-stdin ${{ env.aws_ecr_repo_url }}
- name: Tag the image in the GHCR as ${{ inputs.environment }}
shell: bash
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/app-vue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ jobs:
uses: ./.github/workflows/actions/deploy-to-aws
with:
environment: ${{ env.ENVIRONMENT }}
aws_account: ${{ vars.AWS_ACCOUNT }}
region: ${{ vars.AWS_REGION }}
app_name: ${{ vars.APP_NAME }}
aws_role_arn: ${{ vars.AWS_ROLE_ARN }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
github_image_repo: ${{ env.GITHUB_IMAGE_REPO }}
image_name: ${{ env.IMAGE_NAME }}
Expand Down

0 comments on commit 93a6f48

Please sign in to comment.