Skip to content

Commit

Permalink
ci: fix vars context usage
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaycicekli committed Sep 25, 2024
1 parent 63ec150 commit b23bfd5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,4 @@ jobs:
uses: ./.github/workflows/reusable-docker-publish.yaml
with:
environment: ${{ startsWith(github.ref, 'refs/tags/') && 'prod' || 'dev' }}
aws-region: ${{ vars.AWS_REGION }}
aws-account-id: ${{ vars.AWS_ACCOUNT_ID }}
newrelic-application-guid: ${{ vars.NEWRELIC_APPLICATION_GUID }}
secrets: inherit
18 changes: 4 additions & 14 deletions .github/workflows/reusable-docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ on:
ref:
required: false
type: string
aws-region:
required: true
type: string
aws-account-id:
required: false
type: string
default: '915497967985'
newrelic-application-guid:
required: true
type: string

jobs:
build-and-push:
Expand All @@ -38,7 +28,7 @@ jobs:
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ inputs.aws-region }}
aws-region: ${{ vars.AWS_REGION }}

- name: Configure Node
uses: actions/setup-node@v4
Expand Down Expand Up @@ -107,12 +97,12 @@ jobs:

- name: Build and push Docker image to AWS ECR
run: |
REPO="${{ inputs.aws-account-id }}.dkr.ecr.${{ inputs.aws-region }}.amazonaws.com"
REPO="${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com"
IMAGE="$REPO/$APP_NAME:${{ env.version || env.commit-id }}"
IMAGE_WITH_ENV_TAG="$REPO/$APP_NAME:${{ inputs.environment }}"
docker build -t $IMAGE .
docker tag $IMAGE $IMAGE_WITH_ENV_TAG
aws ecr get-login-password --region ${{ inputs.aws-region }} | docker login --username AWS --password-stdin $REPO
aws ecr get-login-password --region ${{ vars.AWS_REGION }} | docker login --username AWS --password-stdin $REPO
docker push $IMAGE
docker push $IMAGE_WITH_ENV_TAG
Expand All @@ -126,7 +116,7 @@ jobs:
--arg v "${{ env.version }}" \
--arg c "${{ env.commit-id }}" \
--arg e "${{ inputs.environment }}" \
--arg n "${{ inputs.newrelic-application-guid }}" \
--arg n "${{ vars.NEWRELIC_APPLICATION_GUID }}" \
--arg s "$APP_NAME" \
'{"app-name": $a, "branch": $b, "version": $v, "tag": $t, "commit-id": $c, "environment": $e, "newrelic-guid": $n, "sentry-project": $s }'
)
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/scheduled-docker-publish-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,4 @@ jobs:
with:
environment: "prod"
ref: ${{ needs.get-latest-tag.outputs.latest-tag }}
aws-region: ${{ vars.AWS_REGION }}
aws-account-id: ${{ vars.AWS_ACCOUNT_ID }}
newrelic-application-guid: ${{ vars.NEWRELIC_APPLICATION_GUID }}
secrets: inherit

0 comments on commit b23bfd5

Please sign in to comment.