Skip to content

Commit

Permalink
CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
M397749490 committed Jan 7, 2025
1 parent ac8e795 commit f71c4f0
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Image CI
name: CI/CD

on:
push:
Expand All @@ -7,7 +7,7 @@ on:

jobs:
build_docker:
name: Build docker
name: Build Docker
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -19,8 +19,8 @@ jobs:
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
Expand All @@ -29,12 +29,30 @@ jobs:
push: true
platforms: linux/amd64
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/toyou-backend:latest
${{ vars.DOCKERHUB_USERNAME }}/${{ vars.IMAGE_NAME }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max

build_docker_acr:
name: Build Docker ACR
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to ACR
uses: aliyun/acr-login@v1
with:
login-server: https://${{ vars.REGISTRY_ADDRESS }}
username: "${{ vars.REGISTRY_USERNAME }}"
password: "${{ secrets.REGISTRY_PASSWORD }}"
- name: Build and push image
run: |
docker build -t ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest .
docker push ${{ vars.REGISTRY_ADDRESS }}/${{ vars.REGISTRY_NAMESPACE }}/${{ vars.IMAGE_NAME }}:latest
deploy:
name: Deploy
needs: build_docker
needs: [build_docker, build_docker_acr]
runs-on: ubuntu-latest
steps:
- name: SSH To Host
Expand All @@ -45,6 +63,5 @@ jobs:
key: ${{ secrets.SSH_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
cd ${{ secrets.PROJ_PATH }}
sudo docker compose down
cd ${{ secrets.PROJECT_PATH }}
sudo bash ./deploy.sh

0 comments on commit f71c4f0

Please sign in to comment.