Skip to content

Commit

Permalink
[FEAT] cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
yubinquitous committed Mar 13, 2024
1 parent f37ea54 commit 391c1cb
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
build:
name: CI
runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- name: Checkout
Expand All @@ -14,22 +14,25 @@ jobs:
submodules: recursive
token: ${{ secrets.ACTION_TOKEN }} # personal token

# - 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: ${{ secrets.AWS_REGION }}
- 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: ${{ secrets.AWS_REGION }}

# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1

# - name: Docker build, tag, and push image to Amazon ECR
# id: build-image
# run: |
# docker buildx create --use --name arm64-my-builder
# docker buildx build --platform linux/arm64 -t ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ secrets.ECR_IMAGE_TAG }} . --push
# - name: get time for image tag
# id: time
# run: echo "::set-output name=tag::$(date +'%Y%m%d%H%M%S')"

- name: Build image in EC2
id: build-image
run: |
docker build -t be:latest .
deploy:
needs: build
Expand All @@ -40,16 +43,19 @@ jobs:
steps:
- name: Stop and remove previous container
run: |
cd ~/BE
docker-compose down --rmi all
docker rm -f be || true
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1

# - name: Pull image from Amazon ECR and run container
# continue-on-error: true
# run: |
# cd ~/BE
# docker rmi be:
# docker-compose up -d

- name: Pull image from Amazon ECR and run container
continue-on-error: true
run: |
cd ~/BE
docker pull ${{ secrets.ECR_REGISTRY }}/${{ secrets.ECR_REPOSITORY }}:${{ secrets.ECR_IMAGE_TAG }}
docker-compose up -d
docker run -d --name be be:latest

0 comments on commit 391c1cb

Please sign in to comment.