Skip to content

feat: Integração Contínua com Amazon ECR e ECS #27

feat: Integração Contínua com Amazon ECR e ECS

feat: Integração Contínua com Amazon ECR e ECS #27

Workflow file for this run

name: CI App PipeLine
on:
push:
branches: [ "prod" ]
pull_request:
branches: [ "prod" ]
jobs:
app:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Login to Docker Hub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- 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: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Login to Amazon ECR Private
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build Application JAR
run: mvn clean package
- name: List files
run: ls -R
- name: Docker Compose Build
run: docker compose build
- name: Tag and push docker image to Amazon ECR
run: |
docker tag ${{ secrets.DOCKER_USERNAME }}/blog-api-server:latest ${{ secrets.IMAGE_REPO_URL }}:${{ github.run_id }}
docker tag ${{ secrets.DOCKER_USERNAME }}/blog-api-server:latest ${{ secrets.IMAGE_REPO_URL }}:latest
docker push ${{ secrets.IMAGE_REPO_URL }}:${{ github.run_id }}
docker push ${{ secrets.IMAGE_REPO_URL }}:latest
- name: Push to Docker Hub Container Registry
run: |
docker tag ${{ secrets.DOCKER_USERNAME }}/blog-api-server:latest ${{ secrets.DOCKER_USERNAME }}/blog-api-server:${{ github.run_id }}
docker push ${{ secrets.DOCKER_USERNAME }}/blog-api-server:${{ github.run_id }}
docker push ${{ secrets.DOCKER_USERNAME }}/blog-api-server:latest