2023-07-25 18:07:17 +08:00
|
|
|
name: Build Docker Image
|
2022-10-25 09:43:22 +08:00
|
|
|
|
2024-02-08 11:35:59 +08:00
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-10-25 09:43:22 +08:00
|
|
|
on:
|
2022-10-28 23:17:47 +08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- 'main'
|
|
|
|
paths:
|
|
|
|
- 'packages/**'
|
2022-12-13 13:37:32 +08:00
|
|
|
- 'docker/nocobase/**'
|
2023-07-25 18:07:17 +08:00
|
|
|
- 'Dockerfile'
|
|
|
|
- '.github/workflows/build-docker-image.yml'
|
2022-10-28 11:41:48 +08:00
|
|
|
pull_request:
|
2022-10-25 09:43:22 +08:00
|
|
|
branches:
|
|
|
|
- '**'
|
2022-10-28 11:41:48 +08:00
|
|
|
paths:
|
|
|
|
- 'packages/**'
|
2022-12-13 13:37:32 +08:00
|
|
|
- 'docker/nocobase/**'
|
2023-07-25 18:07:17 +08:00
|
|
|
- 'Dockerfile'
|
|
|
|
- '.github/workflows/build-docker-image.yml'
|
2022-10-25 09:43:22 +08:00
|
|
|
|
|
|
|
jobs:
|
2023-07-25 18:07:17 +08:00
|
|
|
build-and-push:
|
2022-12-13 13:37:32 +08:00
|
|
|
if: github.event.pull_request.head.repo.fork != true
|
2022-10-25 09:43:22 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
|
|
verdaccio:
|
2023-08-02 00:07:52 +08:00
|
|
|
image: verdaccio/verdaccio:latest
|
2022-10-25 09:43:22 +08:00
|
|
|
ports:
|
|
|
|
- 4873:4873
|
|
|
|
steps:
|
2022-11-16 12:53:58 +08:00
|
|
|
- name: Checkout
|
2022-10-25 09:43:22 +08:00
|
|
|
uses: actions/checkout@v3
|
2022-11-29 11:31:30 +08:00
|
|
|
with:
|
|
|
|
ssh-key: ${{ secrets.SUBMODULE_SSH_KEY }}
|
|
|
|
submodules: true
|
2022-11-16 12:53:58 +08:00
|
|
|
- name: Set up QEMU
|
2022-10-25 09:43:22 +08:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2022-11-16 12:53:58 +08:00
|
|
|
- name: Set up Docker Buildx
|
2022-10-25 09:43:22 +08:00
|
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
with:
|
|
|
|
driver-opts: network=host
|
2022-11-16 12:53:58 +08:00
|
|
|
- name: Docker meta
|
2022-10-25 09:43:22 +08:00
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v4
|
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
nocobase/nocobase
|
|
|
|
tags: |
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=semver,pattern={{major}}.{{minor}}
|
2023-07-25 18:07:17 +08:00
|
|
|
|
|
|
|
- name: Login to Aliyun Container Registry
|
2022-10-25 09:43:22 +08:00
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ${{ secrets.ALI_DOCKER_REGISTRY }}
|
|
|
|
username: ${{ secrets.ALI_DOCKER_USERNAME }}
|
|
|
|
password: ${{ secrets.ALI_DOCKER_PASSWORD }}
|
2023-07-25 18:07:17 +08:00
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Set tags
|
|
|
|
id: set-tags
|
|
|
|
run: |
|
|
|
|
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
|
|
|
|
echo "::set-output name=tags::${{ steps.meta.outputs.tags }},${{ secrets.ALI_DOCKER_REGISTRY }}/${{ steps.meta.outputs.tags }}"
|
|
|
|
else
|
|
|
|
echo "::set-output name=tags::${{ secrets.ALI_DOCKER_REGISTRY }}/${{ steps.meta.outputs.tags }}"
|
|
|
|
fi
|
|
|
|
|
2022-11-16 12:53:58 +08:00
|
|
|
- name: Build and push
|
2022-10-25 09:43:22 +08:00
|
|
|
uses: docker/build-push-action@v3
|
|
|
|
with:
|
|
|
|
context: .
|
2023-07-25 18:07:17 +08:00
|
|
|
file: Dockerfile
|
2022-11-16 12:53:58 +08:00
|
|
|
build-args: |
|
2022-10-25 09:43:22 +08:00
|
|
|
VERDACCIO_URL=http://localhost:4873/
|
2022-11-16 12:53:58 +08:00
|
|
|
COMMIT_HASH=${GITHUB_SHA}
|
2022-10-25 09:43:22 +08:00
|
|
|
push: true
|
2023-07-25 18:07:17 +08:00
|
|
|
tags: ${{ steps.set-tags.outputs.tags }}
|
|
|
|
|
2022-12-13 10:42:18 +08:00
|
|
|
- name: Deploy NocoBase
|
2022-11-30 16:10:12 +08:00
|
|
|
env:
|
|
|
|
IMAGE_TAG: ${{ steps.meta.outputs.tags }}
|
|
|
|
run: |
|
2022-12-13 10:42:18 +08:00
|
|
|
echo $IMAGE_TAG
|
|
|
|
export APP_NAME=$(echo $IMAGE_TAG | cut -d ":" -f 2)
|
|
|
|
echo $APP_NAME
|
2023-02-08 09:20:17 +08:00
|
|
|
curl --retry 2 --location --request POST "${{secrets.NOCOBASE_DEPLOY_HOST}}$APP_NAME" \
|
2022-12-13 10:42:18 +08:00
|
|
|
--header 'Content-Type: application/json' \
|
|
|
|
-d "{
|
|
|
|
\"tag\": \"$APP_NAME\",
|
|
|
|
\"dialect\": \"postgres\"
|
|
|
|
}"
|