Skip to content

Commit

Permalink
Create pipeline.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dopic authored Sep 18, 2024
1 parent 1f114ba commit 7dcd465
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build the Docker image
run: docker build . --tag 256696114092.dkr.ecr.us-east-1.amazonaws.com/omniscope/app:${{ github.run_id }} --tag 256696114092.dkr.ecr.us-east-1.amazonaws.com/omniscope/app:latest

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::256696114092:role/GithubDeploymentRole
role-session-name: GithubSession
aws-region: us-east-1

- name: Amazon ECR Login
uses: aws-actions/amazon-ecr-login@v2

- name: Push Docker images
run: |
docker image push 256696114092.dkr.ecr.us-east-1.amazonaws.com/omniscope/app:${{ github.run_id }}
docker image push 256696114092.dkr.ecr.us-east-1.amazonaws.com/omniscope/app:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v3
with:
role-to-assume: arn:aws:iam::256696114092:role/GithubDeploymentRole
role-session-name: GithubSession
aws-region: us-east-1

#TODO: Atualizar a task definition e o service
- name: ECS Restart Service
run: aws ecs update-service --cluster arn:aws:ecs:us-east-1:256696114092:cluster/fargate-spot-stack-ecscluster7830E7B5-5A2jZtnQeSlV --service omniscope-app --region us-east-1 --force-new-deployment

# aws ecs update-service --cluster <nome_do_cluster> --service <nome_do_serviço> --force-new-deployment
# - name: ECS Restart Service
# uses: apideck-libraries/ecs-restart-service@v1
# with:
# service: ominiscope-app
# # The short name or full Amazon Resource Name (ARN) of the cluster that your service runs on. If you do not specify a cluster, the default cluster is assumed.
# cluster: arn:aws:ecs:us-east-1:256696114092:cluster/fargate-spot-stack-ecscluster7830E7B5-5A2jZtnQeSlV







0 comments on commit 7dcd465

Please sign in to comment.