Skip to content

Merge pull request #637 from chenshunliang/main #1460

Merge pull request #637 from chenshunliang/main

Merge pull request #637 from chenshunliang/main #1460

Workflow file for this run

name: build
on:
push:
branches:
- 'main'
- 'develop'
tags:
- 'v*.*.*'
paths-ignore: ['**/*.md', '*.md', '.dockerignore', '.gitignore', '.vscode/*']
pull_request:
branches:
- 'main'
- 'feat/*'
- 'fix/*'
- 'enhancement/*'
- 'develop'
paths-ignore: ['**/*.md', '*.md', '.dockerignore', '.gitignore', '.vscode/*']
env:
ALI_REGISTRY: ${{ secrets.ALI_RSY_HOST }}
DOCKER_HUB_REGISTRY: ${{ secrets.DOCKER_RSY }}
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.3
- name: Repo metadata
id: repo
uses: actions/github-script@v3
with:
script: |
const repo = await github.repos.get(context.repo)
return repo.data
- name: Prepare
id: prepare
run: |
VERSION=latest
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
elif [[ $GITHUB_REF == refs/heads/* ]]; then
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then
VERSION=main
fi
elif [[ $GITHUB_REF == refs/pull/* ]]; then
VERSION=pr-${{ github.event.number }}
fi
TAGS="${VERSION}"
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build dashboard dist
env:
VUE_APP_DATE: ${{ steps.prepare.outputs.created }}
VUE_APP_RELEASE: ${{ steps.prepare.outputs.tags }}
run: echo $VUE_APP_DATE && echo $VUE_APP_RELEASE && export NODE_OPTIONS=--max-old-space-size=32768 && npm install -g pnpm && pnpm install && pnpm build
- name: Set up QEMU
if: github.event_name != 'pull_request'
uses: docker/setup-qemu-action@v1
- name: Docker Setup Buildx
if: github.event_name != 'pull_request'
uses: docker/setup-buildx-action@v1
- name: Login to ali registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.ALI_REGISTRY }}
username: ${{ secrets.ALI_RSY_USER }}
password: ${{ secrets.ALI_RSY_PASSWORD }}
- name: Login to docker hub registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.DOCKER_HUB_REGISTRY }}
username: ${{ secrets.DOCKER_RSY_USER }}
password: ${{ secrets.DOCKER_RSY_PASSWORD }}
- name: Extract Docker metadata
if: github.event_name != 'pull_request'
id: meta
uses: docker/metadata-action@v3.6.2
with:
images: ${{ env.ALI_REGISTRY }}/${{ env.IMAGE_NAME }},${{ env.DOCKER_HUB_REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v2.9.0
with:
context: ./apps/kubegems
file: ./apps/kubegems/Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and push Docker image for arm64
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v2.9.0
with:
context: ./apps/kubegems
file: ./apps/kubegems/arm64.Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}-arm64
labels: ${{ steps.meta.outputs.labels }}-arm64