Skip to content

v1.14.1

v1.14.1 #43

name: Release Dongtai web
on:
release:
types: [ created, edited ]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: start-build
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.WEBHOOK_URL }}
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:构建开始\n项目:${{github.repository}}\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'
- name: checkout
uses: actions/checkout@v2
- name: setup nodejs
uses: actions/setup-node@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DONGTAI_DOCKERHUB_USERNAME }}
password: ${{ secrets.DONGTAI_DOCKERHUB_TOKEN }}
# - name: Login to AliyunRegistry
# uses: docker/login-action@v1
# with:
# registry: ${{ secrets.ALIYUN_REGISTRY }}
# username: ${{ secrets.ALIYUN_DOCKERHUB_USER }}
# password: ${{ secrets.ALIYUN_DOCKERHUB_PASSWORD }}
- name: test and build
run: |
npm ci
npm test
npm run build --if-present
- id: release
run: |
TAG_NAME=${{ github.event.release.tag_name }}
ID=`echo ${TAG_NAME##v}`
echo "::set-output name=VERSION::$ID"
- name: Release DongTai-WEB
run: |
bash .github/workflows/scripts/release_version.sh "${{ steps.release.outputs.VERSION }}"
- name: Generate version file
run: |
cd ${{ github.workspace }} && \
echo "${{ github.event.repository.name }},version,${{ steps.release.outputs.VERSION }}" >> dist/version.txt && \
echo "${{ github.event.repository.name }},commit_hash,${GITHUB_SHA}" >> dist/version.txt && \
cat dist/version.txt \
- uses: manyuanrong/setup-ossutil@v2.0
with:
endpoint: "oss-cn-beijing.aliyuncs.com"
access-key-id: ${{ secrets.OSS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
- name: Upload version file to oss
run: |
ossutil cp -rf dist/version.txt oss://huoqi-public/iast/release-version/${{ github.event.repository.name }}/${{ steps.release.outputs.VERSION }}/version.txt
- name: Merge all version file
run: |
echo "DongTai,version,${{ steps.release.outputs.VERSION }}" > dist/version.txt
ossutil cp oss://huoqi-public/iast/release-version/DongTai-web/${{ steps.release.outputs.VERSION }}/version.txt DongTai-web.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-webapi/${{ steps.release.outputs.VERSION }}/version.txt DongTai-webapi.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-openapi/${{ steps.release.outputs.VERSION }}/version.txt DongTai-openapi.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-engine/${{ steps.release.outputs.VERSION }}/version.txt DongTai-engine.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-agent-python/${{ steps.release.outputs.VERSION }}/version.txt DongTai-agent-python.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-agent-java/${{ steps.release.outputs.VERSION }}/version.txt DongTai-agent-java.version.txt || true
ossutil cp oss://huoqi-public/iast/release-version/DongTai-agent-php/${{ steps.release.outputs.VERSION }}/version.txt DongTai-agent-php.version.txt || true
cat *.version.txt >> dist/version.txt
cat dist/version.txt
- name: Save image to tar file
run: |
docker save dongtai/dongtai-web:${{ steps.release.outputs.version }} | gzip > /tmp/dongtai-web-${{ steps.release.outputs.version }}.tar.gz
- name: Setup Ossutil
uses: manyuanrong/setup-ossutil@v2.0
with:
endpoint: ${{ secrets.OSS_ENDPOINT }}
access-key-id: ${{ secrets.OSS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
- name: Upload images to oss
run: |
ossutil cp /tmp/dongtai-web-${{ steps.release.outputs.version }}.tar.gz oss://huoqi-public/iast/server-package/${{ steps.release.outputs.version }}/
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
dongtai/dongtai-web:${{ steps.release.outputs.VERSION }}
dongtai/dongtai-web:latest
#- name: Deploy to staging
# uses: wahyd4/kubectl-helm-action@master
# env:
# KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
# with:
# args: |
# find deploy/deploy-eks-iast-saas-web-prod.yml -type f -exec sed -i 's/VERSION/${{ steps.release.outputs.VERSION }}/g' {} \;
# ls deploy/deploy-eks-iast-saas-web-prod.yml | xargs -I {} kubectl apply -f {}
- name: finish build
uses: joelwmale/webhook-action@master
with:
url: ${{ secrets.WEBHOOK_URL }}
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:构建开始\n项目:${{github.repository}}\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'