Skip to content

change header text

change header text #20

Workflow file for this run

name: LabCrud CI Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: labcrud-repository
ECS_SERVICE: labcrud-service
ECS_CLUSTER: labcrud-cluster
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Maven
run: mvn clean package -DskipTests
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build and push Docker image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Retrieve AccessRoleArn from SSM
id: access_role
run: |
ACCESS_ROLE_ARN=$(aws ssm get-parameter --name "/AccessRoleArn" --query "Parameter.Value" --output text)
echo "::set-output name=access_role_arn::$ACCESS_ROLE_ARN"
- name: Retrieve AutoScalingConfigurationArn from SSM
id: autoscaling_config
run: |
AUTO_SCALING_ARN=$(aws ssm get-parameter --name "/AutoScalingConfigurationArn" --query "Parameter.Value" --output text)
echo "::set-output name=auto_scaling_arn::$AUTO_SCALING_ARN"
- name: Retrieve ImageIdentifier from SSM
id: image_id
run: |
IMAGE_IDENTIFIER=$(aws ssm get-parameter --name "/ImageIdentifier" --query "Parameter.Value" --output text)
echo "::set-output name=image_identifier::$IMAGE_IDENTIFIER"
- name: Deploy to AppRunner
run: |
aws apprunner create-service \
--service-name labcrud-apprunner \
--source-configuration '{
"ImageRepository": {
"ImageIdentifier": "${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}",
"ImageRepositoryType": "ECR",
"ImageConfiguration": {
"RuntimeEnvironmentVariables": {
"JAVA_OPTS": "-Xms512m -Xmx1024m"
}
}
},
"AutoDeploymentsEnabled": true,
"AuthenticationConfiguration": {
"AccessRoleArn": "${{ steps.access_role.outputs.access_role_arn }}"
}
}' \
--instance-configuration '{
"Cpu": "1024",
"Memory": "2048"
}' \
--health-check-configuration '{
"Protocol": "HTTP",
"Path": "/",
"Interval": 10,
"Timeout": 5,
"HealthyThreshold": 2,
"UnhealthyThreshold": 3
}' \
--auto-scaling-configuration-arn "${{ steps.autoscaling_config.outputs.auto_scaling_arn }}"