Skip to content

Commit

Permalink
feat:action token
Browse files Browse the repository at this point in the history
  • Loading branch information
yuehuazhang committed Jul 27, 2024
1 parent 6dfb9e4 commit c18570b
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions .github/workflows/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ jobs:
remove-docker-images: 'true'
- name: Checkout Repository
uses: actions/checkout@v4
# - name: Get Latest Release
# id: get_version
# run: |
# VERSION=$(curl --silent "https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .tag_name)
# echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Set DockerImage Tag
id: imageTag
run: echo "image_tag=${RELEASE_VERSION}-$(git rev-parse --short HEAD)-$(date +%Y%m%d)" >> $GITHUB_ENV
Expand All @@ -107,13 +102,24 @@ jobs:
password: ${{ secrets.CCR_REGISTRY_PASSWORD }}
- name: Show Runner Disk
run: df -hT
# - name: Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# context: ./docker
# file: ./docker/Dockerfile
# push: true
# tags: |
# chatimage/chatchat:${{ env.image_tag }}
# ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:${{ env.image_tag }}
# platforms: |
# linux/amd64, linux/arm64
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./docker
file: ./docker/Dockerfile
push: true
tags: |
tags: |
chatimage/chatchat:${{ env.image_tag }}
ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:${{ env.image_tag }}
platforms: |
Expand All @@ -124,23 +130,30 @@ jobs:
run: docker logout ccr.ccs.tencentyun.com
- name: Update README and docker-compose.yaml
run: |
# 拉取远程仓库的最新更改
git pull origin master
# 更新文件内容
sed -i -E "s|chatimage/chatchat:[a-zA-Z0-9._-]+|chatimage/chatchat:${{ env.image_tag }}|g" README.md README_en.md docker/docker-compose.yaml
sed -i -E "s|ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:[a-zA-Z0-9._-]+|ccr.ccs.tencentyun.com/langchain-chatchat/chatchat:${{ env.image_tag }}|g" README.md README_en.md docker/docker-compose.yaml
# 配置 Git 用户信息
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"


# 创建新的分支
git checkout -b update-docker-image-tag-${{ env.image_tag }}

# 提交更改
git commit -am "feat: update docker image tag to ${{ env.image_tag }}"

# 推送更改到远程仓库
git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/yuehua-s/Langchain-Chatchat.git HEAD:master || {
echo "Push failed. Attempting to pull remote changes and re-push..."
git pull --rebase origin master
git push https://x-access-token:${{ secrets.PAT_TOKEN }}@github.com/yuehua-s/Langchain-Chatchat.git HEAD:master
}

# 推送到新的分支
git push origin update-docker-image-tag-${{ env.image_tag }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "feat: update docker image tag to ${{ env.image_tag }}"
branch: update-docker-image-tag-${{ env.image_tag }}
title: "Update Docker image tag to ${{ env.image_tag }}"
body: "This PR updates the Docker image tag to ${{ env.image_tag }}."
labels: |
docker
automated-pr

0 comments on commit c18570b

Please sign in to comment.