trigger-at-all-in-one #136
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: at-all-in-one-image-builder | |
on: | |
repository_dispatch: | |
types: [trigger-at-all-in-one] | |
push: | |
branches: | |
- main | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Aliyun Docker Registry | |
run: echo ${{ secrets.ALIYUN_DOCKER_REGISTRY_PASSWORD }} | docker login --username=${{ secrets.ALIYUN_DOCKER_REGISTRY_USER }} --password-stdin registry.cn-shanghai.aliyuncs.com | |
- name: Login to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} # 使用访问令牌进行身份验证 | |
# Read version from version.txt file | |
- name: Get the version | |
id: get_version | |
run: echo "VERSION=$(cat version.txt)" >> $GITHUB_ENV | |
- name: Build, tag and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . # 使用当前目录作为上下文 | |
file: Dockerfile # Dockerfile的位置 | |
push: true # 推送镜像到阿里云镜像仓库 | |
tags: | | |
registry.cn-shanghai.aliyuncs.com/datamini/asktable-all-in-one:${{ env.VERSION }} | |
registry.cn-shanghai.aliyuncs.com/datamini/asktable-all-in-one:latest | |
datamini/asktable-all-in-one:latest | |
platforms: linux/amd64 # ,linux/arm64 | |
cache-from: type=gha # 启用 GitHub Actions 缓存,适用于跨工作流缓存 | |
cache-to: type=gha,mode=max # 启用缓存并优化构建 | |
- name: Execute deployment script # 只更新重启,不提供 docker-compose.yaml 文件 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SERVER_HOST_SH4 }} | |
username: ${{ secrets.SERVER_USER }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
port: 22 | |
script: | | |
# 进入部署目录 | |
cd /root/sh4/at-all-in-one/ | |
# 拉取最新镜像 | |
docker-compose pull && docker-compose down | |
# 启动容器 | |
docker-compose up -d |