Skip to content

Build Push Base API

Build Push Base API #1

name: Build Push Base API
on:
workflow_dispatch:
env:
dockerhub_domain: "hub.docker.com"
namespace: kennethcse
context: ./api
image_name: dify-base-api
image_tag: "latest"
image_url: ${dockerhub_domain}/${namespace}/${image_name}:${image_tag}
dockerhub_user: ${{ secrets.DOCKERHUB_USER }}
dockerhub_token: ${{ secrets.DOCKERHUB_TOKEN }}
qywechat_webhook_token: ${{ vars.QYWECHAT_WEBHOOK_TOKEN}}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build Image
run: docker build -t ${{env.image_url}} ./${{env.context}}/Base.Dockerfile
# 登录dockerhub
- name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: ${{ env.dockerhub_domain }}
username: ${{ env.dockerhub_user }}
password: ${{ env.dockerhub_token }}
- name: Docker push
run: docker push ${{ env.image_url }}
- name: Get pre step result output image_pull_url
run: echo "The time was ${{ steps.buildAndPushImage.outputs.image_pull_url }}"
- name: Send Webhook
uses: fjogeleit/http-request-action@v1
with:
url: 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${{ env.qywechat_webhook_token }}'
method: 'POST'
customHeaders: '{"Content-Type": "application/json"}'
data: '{ "msgtype": "text", "text": { "content": "[GitHub Actions] ${{env.image_name}}:${{env.image_tag}} 构建推送成功,可后续操作。如Jenkins构建等。"} }'