diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml index 3e6f05a..3aa1685 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflows/aws.yml @@ -46,7 +46,7 @@ permissions: jobs: deploy: name: Deploy on AWS - runs-on: self-hosted + runs-on: ubuntu-latest environment: production steps: @@ -56,8 +56,11 @@ jobs: with: java-version: 11 - name: Build with Maven - run: mvn -B package --file pom.xml - + run: | + cd app/ + mvn -B package --file pom.xml + cd .. + - name: Checkout uses: actions/checkout@v3 @@ -70,24 +73,23 @@ jobs: - name: Login to Amazon ECR id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + uses: aws-actions/amazon-ecr-login@v2 - name: Build, tag, and push image to Amazon ECR id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: $ECR_REPOSITORY + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} IMAGE_TAG: ${{ github.sha }} + working-directory: ./app run: | # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - cd app/ - mvn build package - cd .. docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --build-arg ACCESS_ARG=${{ secrets.AWS_ACCESS_KEY_ID }} --build-arg SECRET_ARG=${{ secrets.AWS_SECRET_ACCESS_KEY }} . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + cd .. - name: Fill in the new image ID in the Amazon ECS task definition id: task-def