1
+ name : Build Push Web Release Image
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - release/*
7
+ workflow_dispatch :
8
+
9
+ env :
10
+ # 阿里云
11
+ dockerhub_domain : " registry.cn-shenzhen.aliyuncs.com"
12
+ namespace : investoday_x
13
+ dockerhub_user : ${{ secrets.ALIYUN_DOCKER_USERNAME }}
14
+ dockerhub_token : ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
15
+
16
+ context : web
17
+ image_name : dify-web
18
+ image_tag : " "
19
+ image_url : ${dockerhub_domain}/${namespace}/${image_name}
20
+ qywechat_webhook_token : ${{ vars.QYWECHAT_WEBHOOK_TOKEN}}
21
+
22
+ jobs :
23
+ build-and-push :
24
+ runs-on : ubuntu-latest
25
+ steps :
26
+ - name : Checkout Code
27
+ uses : actions/checkout@v2
28
+
29
+ - name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v1
31
+
32
+ - name : Print Current Path
33
+ run : pwd && ls
34
+
35
+ - name : Set IMAGE_TAG based on branch name
36
+ run : |
37
+ if [[ "${GITHUB_REF#refs/heads/}" =~ ^release/ ]]; then
38
+ # 假设你想要使用分支名称作为标签
39
+ image_tag="${GITHUB_REF#refs/heads/release/}"
40
+ echo "image_tag=${image_tag}" >> $GITHUB_ENV
41
+ echo "Current tag set to: $image_tag"
42
+ fi
43
+
44
+ - name : Build Image
45
+ run : docker build -t ${{env.image_url}}:${{ env.image_tag }} ${{env.context}}/.
46
+
47
+ # 登录dockerhub
48
+ - name : Login to DockerHub
49
+ uses : docker/login-action@v3
50
+ with :
51
+ registry : ${{ env.dockerhub_domain }}
52
+ username : ${{ env.dockerhub_user }}
53
+ password : ${{ env.dockerhub_token }}
54
+
55
+ - name : Docker push
56
+ run : docker push ${{ env.image_url }}:${{ env.image_tag }}
57
+
58
+ - name : Get pre step result output image_pull_url
59
+ run : echo "The time was ${{ steps.buildAndPushImage.outputs.image_pull_url }}"
60
+
61
+ - name : Send Webhook
62
+ uses : fjogeleit/http-request-action@v1
63
+ with :
64
+ url : ' https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${{ env.qywechat_webhook_token }}'
65
+ method : ' POST'
66
+ customHeaders : ' {"Content-Type": "application/json"}'
67
+ data : ' { "msgtype": "text", "text": { "content": "[GitHub Actions] ${{env.image_name}}:${{env.image_tag}} 构建推送成功。"} }'
0 commit comments