48 lines
1.9 KiB
YAML
48 lines
1.9 KiB
YAML
name: Build apigo
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
env:
|
|
IMAGE_NAME: apigo.cc/ag/apigo:${{ gitea.ref_name }}
|
|
IMAGE_LATEST: apigo.cc/ag/apigo:latest
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: apigo.cc/ag/ag:latest
|
|
steps:
|
|
- name: Build
|
|
run: |
|
|
mkdir apigo
|
|
cd apigo
|
|
sed -i "s/version: v0.0.1/version: ${{ gitea.ref_name }}/" apigo.yml
|
|
sed -i "s#Hello world#please mount app in /app/main.js, example: docker run --rm -it -v /your/app:/app apigo.cc/ag/apigo#" main.js
|
|
ag i
|
|
ag b
|
|
upx build/apigo_linux_amd64
|
|
docker build -t ${{ env.IMAGE_NAME }} -t ${{ env.IMAGE_LATEST }} .
|
|
echo "${{ secrets.DOCKERPUSHKEY }}" | docker login apigo.cc -u "${{ gitea.actor }}" --password-stdin
|
|
docker push ${{ env.IMAGE_NAME }}
|
|
docker push ${{ env.IMAGE_LATEST }}
|
|
docker logout apigo.cc
|
|
|
|
- name: Send notification
|
|
if: always()
|
|
run: |
|
|
BUILD_URL="https://apigo.cc/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}"
|
|
if [ "${{ success() }}" = "true" ]; then
|
|
CONTENT="✅发布并测试成功: ${{ env.REPO_NAME }}@${{ env.VERSION_TAG }}\n镜像: ${{ env.IMAGE_NAME }}\n构建地址: ${BUILD_URL}"
|
|
else
|
|
CONTENT="🚨发布并测试失败: ${{ env.REPO_NAME }}@${{ env.VERSION_TAG }}\n构建地址: ${BUILD_URL}"
|
|
fi
|
|
echo $CONTENT
|
|
|
|
TIMESTAMP=$(date +%s)000
|
|
STRING_TO_SIGN=$(printf "%s\n%s" "$TIMESTAMP" "${{ secrets.DINGSECRET }}")
|
|
SIGN=$(echo -n "$STRING_TO_SIGN" | openssl dgst -sha256 -hmac "${{ secrets.DINGSECRET }}" -binary | base64 | tr -d '\n' | sed -e 's/+/%2B/g' -e 's/\//%2F/g' -e 's/=/%3D/g')
|
|
curl -s -X POST "${{ secrets.DINGURL }}×tamp=${TIMESTAMP}&sign=${SIGN}" -H "Content-Type: application/json" -d "{\"msgtype\": \"text\",\"text\": {\"content\": \"${CONTENT}\"}}"
|