diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..909d53d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,41 @@ +name: Push to Amazon ECR + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + amazon_ecr_push: + name: Amazon ECR push + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 + with: + registry-type: public + + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + REGISTRY: ${{ steps.login-ecr.outputs.registry }} + REGISTRY_ALIAS: i9q6f9d6 + REPOSITORY: pm-robotdreams-docker-test + IMAGE_TAG: ${{ github.sha }} + run: | + docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG . + docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG + echo "image=$REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT