Skip to content

Commit

Permalink
[update]
Browse files Browse the repository at this point in the history
  • Loading branch information
alvo254 committed Jun 10, 2024
1 parent 4fbc80f commit 133c83a
Showing 1 changed file with 79 additions and 18 deletions.
97 changes: 79 additions & 18 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,43 +60,104 @@ jobs:

- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
- name: list dirs
run: |
ls -la
ls frontend

- name: Build, tag, and push image to Docker Hub
env:
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG -f frontend/Dockerfile .
docker push $DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG
echo "image=$DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV
- name: Set container image variable
run: echo "CONTAINER_IMAGE=fitnesshero" >> $GITHUB_ENV

echo "CONTAINER_IMAGE=$DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV
- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: "1.8.5" # Specify the Terraform version

# - name: Terraform Init and Apply
# run: |
# terraform init
# terraform apply -auto-approve -var="container_image=${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }}:${{ env.IMAGE_TAG }}"

terraform_version: "1.8.5"

- name: Apply Terraform
run: |
terraform init
terraform apply -auto-approve -var="container_image=${{ env.CONTAINER_IMAGE }}"
- name: Update ECS Service
run: |
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment
env:
AWS_DEFAULT_REGION: ${{ env.AWS_REGION }}

# name: Deploy to Amazon ECS

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

# env:
# AWS_REGION: us-east-1
# DOCKER_USERNAME: alvin254
# DOCKER_REPOSITORY: fitnesshero
# ECS_SERVICE: app-service
# ECS_CLUSTER: cloudific
# CONTAINER_NAME: app

# permissions:
# contents: read

# jobs:
# deploy:
# name: Deploy
# runs-on: ubuntu-latest
# environment: production

# steps:
# - name: Checkout
# uses: actions/checkout@v4

# - 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: Log in to Docker Hub
# run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
# - name: list dirs
# run: |
# ls -la
# ls frontend


# - name: Build, tag, and push image to Docker Hub
# env:
# IMAGE_TAG: ${{ github.sha }}
# run: |
# docker build -t $DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG -f frontend/Dockerfile .
# docker push $DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG
# echo "image=$DOCKER_USERNAME/$DOCKER_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV

# - name: Set container image variable
# run: echo "CONTAINER_IMAGE=fitnesshero" >> $GITHUB_ENV


# - name: Set up Terraform
# uses: hashicorp/setup-terraform@v1
# with:
# terraform_version: "1.8.5" # Specify the Terraform version

# # - name: Terraform Init and Apply
# # run: |
# # terraform init
# # terraform apply -auto-approve -var="container_image=${{ env.DOCKER_USERNAME }}/${{ env.DOCKER_REPOSITORY }}:${{ env.IMAGE_TAG }}"


# - name: Apply Terraform
# run: |
# terraform init
# terraform apply -auto-approve -var="container_image=${{ env.CONTAINER_IMAGE }}"


# - name: Update ECS Service
# run: |
# aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment
# env:
# AWS_DEFAULT_REGION: ${{ env.AWS_REGION }}

0 comments on commit 133c83a

Please sign in to comment.