feat: add notify service #7
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: Build Docker CI | |
on: | |
push: | |
branches: [ master ] | |
# pull_request: | |
# branches: [ master ] | |
env: | |
TKE_DOCKER_HUB: ccr.ccs.tencentyun.com | |
TKE_IMAGE_URL: ccr.ccs.tencentyun.com/hejunwei/microservices | |
TKE_REGION: ap-chengdu | |
TKE_CLUSTER_ID: cls-kj6srqvx | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.18 | |
- name: Build Go | |
run: CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' . | |
- name: Test | |
run: go test -v | |
- name: Generate env file | |
run: sed -e 's/DB_HOST=/DB_HOST=${{secrets.DB_HOST}}/' | |
-e 's/DB_PASSWORD=/DB_PASSWORD=${{secrets.DB_PASSWORD}}/' .env.example > .env | |
- name: Export Date Env | |
id: CURRENT_DATE | |
run: echo "::set-output name=date::$(TZ=Asia/Shanghai date +'%Y-%m-%d-%H-%M-%S')" | |
- name: Build the Docker image | |
run: docker build -t ${TKE_IMAGE_URL}:${{steps.CURRENT_DATE.outputs.date}} . | |
- name: Login TKE Registry | |
run: docker login ${TKE_DOCKER_HUB} --username="${{secrets.TENCENT_CLOUD_ACCOUNT_ID}}" -p "${{ secrets.TKE_REGISTRY_PASSWORD }}" | |
# Push the Docker image to TKE Registry | |
- name: Publish | |
run: docker push ${TKE_IMAGE_URL}:${{steps.CURRENT_DATE.outputs.date}} |