1+ name : Deploy to AWS
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ workflow_dispatch :
7+
8+ jobs :
9+ build-and-deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout repository
14+ uses : actions/checkout@v4
15+
16+ - name : Configure AWS credentials
17+ uses : aws-actions/configure-aws-credentials@v4
18+ with :
19+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
20+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21+ aws-region : ${{ secrets.AWS_REGION }}
22+
23+ - name : Login to Amazon ECR
24+ id : login-ecr
25+ uses : aws-actions/amazon-ecr-login@v2
26+
27+ - name : Build, tag, and push image to Amazon ECR
28+ env :
29+ ECR_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
30+ ECR_REPOSITORY : spotify-data-explorer
31+ IMAGE_TAG : ${{ github.sha }}
32+ run : |
33+ docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
34+ docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
35+ docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
36+ docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
37+
38+ - name : Deploy to AWS App Runner
39+ id : deploy-apprunner
40+ uses : awslabs/amazon-app-runner-deploy@main
41+ with :
42+ service : spotify-data-explorer
43+ image : ${{ steps.login-ecr.outputs.registry }}/spotify-data-explorer:latest
44+ access-role-arn : ${{ secrets.APPRUNNER_SERVICE_ROLE_ARN }}
45+ region : ${{ secrets.AWS_REGION }}
46+ cpu : 1
47+ memory : 2
48+ port : 5000
49+ wait-for-service-stability : true
50+
51+ - name : App Runner output
52+ run : echo "App runner URL ${{ steps.deploy-apprunner.outputs.service-url }}"
0 commit comments