Skip to content

Commit

Permalink
final product
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliaup committed May 1, 2024
1 parent 9e4ff0c commit ee7bb19
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 9 deletions.
57 changes: 51 additions & 6 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::381492107876:role/IIC2173-2
# aws-region: us-east-1

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand All @@ -51,3 +45,54 @@ jobs:
docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
# Deploy a EC2 instance

deploy-to-ec2:
runs-on: ubuntu-latest
if: ${{always()}}
# Tiene el requisito de que el job de antes funcione
needs: [build-and-push]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID0}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY0}}
aws-region: us-east-1

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# role-to-assume: arn:aws:iam::....
# aws-region: us-east-1

- name: Login to Amazon ECR
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
mask-password: "true"

- name: Zip artifact to deploy
run: |
zip -r deploy.zip scripts/ appspec.yml docker-compose.production.yml
- name: Copy Zip to S3
run: |
aws s3 cp deploy.zip s3://iic2173/deploy.zip
- name: Create CodeDeploy Deployment
id: create-deployment-trigger
run: |
deploymentId=$(aws deploy create-deployment --application-name \
IIC2173-CD-Ayudantia --deployment-group-name IIC2173-Group --region us-east-2 \
--s3-location bucket=iic2173,key=deploy.zip,bundleType=zip \
--description "Automatic deployment from githubactions commit ${{github.sha}}" | jq -r '.deploymentId')
echo "DeploymentId=$deploymentId" >> $GITHUB_OUTPUT
- name: Wait for deployment to finish
run: |
aws deploy wait deployment-successful --deployment-id ${{ steps.create-deployment-trigger.outputs.deploymentId }} --region us-east-2
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
./aws
aws
info.txt
Key_Emii.pem
Key_Emii.pem
Ayudantia-iic2173.pem
./Ayudantia-iic2173.pem
3 changes: 3 additions & 0 deletions Ayudantia-iic2173.pem:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
HostUrl=https://us-east-2.console.aws.amazon.com/
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ https://github.com/aws-actions/configure-aws-credentials


## CodeDeploy + Automatización Deploy
https://docs.aws.amazon.com/codedeploy/latest/userguide/getting-started-codedeploy.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/tutorials-on-premises-instance.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/security-iam.html

Expand Down
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app.use(bodyParser.json());

// GET endpoint
app.get('/', (req, res) => {
res.send('Hello World! This is a GET request jaja part 2');
res.send('Hello World! This is a GET request jaja Funciono!');
});

// POST endpoint
Expand Down

0 comments on commit ee7bb19

Please sign in to comment.