This commit is contained in:
devad 2024-09-10 22:34:31 +08:00
parent 725ea39869
commit 1aa1cecfbf
1 changed files with 13 additions and 7 deletions

View File

@ -11,6 +11,7 @@ on:
env:
REGISTRY: registry.cn-hangzhou.aliyuncs.com # 修改为你的阿里云镜像仓库地址
IMAGE_NAME: jcce/pcm-core-api # 修改为你的阿里云镜像仓库名称
IMAGE_TAG: latest
jobs:
build:
@ -24,16 +25,20 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log into Alibaba Cloud Container Registry
if: github.event_name != 'pull_request'
uses: aliyun/acr-login@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.ALIYUN_PASSWORD }}
login-server: ${{ env.REGISTRY }}
- name: Build and push image
env:
IMAGE_TAG: latest
- name: Build and push
run: |
docker build -t ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{env.IMAGE_TAG}} .
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{env.IMAGE_TAG}}
@ -46,4 +51,5 @@ jobs:
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- name: SSH to remote server and restart deployment
if: github.event_name != 'pull_request'
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "kubectl rollout restart deployment ${{ secrets.SSH_DEPLOYMENT }} -n ${{ secrets.SSH_NAMESPACE }}"