mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 13:29:01 +08:00
Merge pull request #593 from ybettan/push-workflow-pr
ci: adding 'push' workflow
This commit is contained in:
commit
9808c03d6d
182
.github/workflows/push.yaml
vendored
182
.github/workflows/push.yaml
vendored
@ -1,172 +1,72 @@
|
||||
name: push-pipeline
|
||||
name: push
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- ^v[0-9]*.[0-9]*.x$
|
||||
tags:
|
||||
- "*"
|
||||
# pull_request:
|
||||
# branches:
|
||||
# - main
|
||||
# - v*
|
||||
# paths:
|
||||
# - 'pkg/**'
|
||||
# - 'frontend/**'
|
||||
paths:
|
||||
- 'pkg/query-service/**'
|
||||
- 'frontend/**'
|
||||
|
||||
jobs:
|
||||
get-envs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
- shell: bash
|
||||
run: |
|
||||
img_tag=""
|
||||
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
|
||||
if [ ${array[1]} == "tags" ]
|
||||
then
|
||||
echo "tag build"
|
||||
img_tag=${GITHUB_REF#refs/*/v}
|
||||
elif [ ${array[1]} == "pull" ]
|
||||
then
|
||||
img_tag="pull-${{ github.event.number }}"
|
||||
else
|
||||
echo "non tag build"
|
||||
img_tag="latest"
|
||||
fi
|
||||
# This is a condition where image tag looks like "pull/<pullrequest-name>" during pull request build
|
||||
NEW_IMG_TAG=`echo $img_tag | sed "s/\//-/g"`
|
||||
echo $NEW_IMG_TAG
|
||||
echo export IMG_TAG=$NEW_IMG_TAG >> env-vars
|
||||
echo export FRONTEND_IMAGE="frontend" >> env-vars
|
||||
echo export QUERY_SERVICE="query-service" >> env-vars
|
||||
echo export FLATTENER_PROCESSOR="flattener-processor" >> env-vars
|
||||
|
||||
- name: Uploading envs
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: env_artifact
|
||||
path: env-vars
|
||||
|
||||
build-and-push-frontend:
|
||||
image-build-and-push-query-service:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- get-envs
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Downloading image artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: env_artifact
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- uses: benjlevesque/short-sha@v1.2
|
||||
id: short-sha
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v5.1
|
||||
- name: Build and push docker image
|
||||
env:
|
||||
DOCKER_TAG: ${{ steps.short-sha.outputs.sha }}
|
||||
DOCKER_SECOND_TAG: ${{ steps.branch-name.outputs.current_branch }}
|
||||
run: make build-push-query-service
|
||||
|
||||
- name: Build & Push Frontend Docker Image
|
||||
shell: bash
|
||||
env:
|
||||
FRONTEND_DIRECTORY: "frontend"
|
||||
REPONAME: ${{ secrets.REPONAME }}
|
||||
FRONTEND_DOCKER_IMAGE: ${FRONTEND_IMAGE}
|
||||
DOCKER_TAG: ${IMG_TAG}
|
||||
run: |
|
||||
branch=${GITHUB_REF#refs/*/}
|
||||
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
|
||||
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [ ${array[1]} == "pull" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
|
||||
then
|
||||
source env-vars
|
||||
make build-push-frontend
|
||||
fi
|
||||
|
||||
build-and-push-query-service:
|
||||
image-build-and-push-frontend:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- get-envs
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Downloading image artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: env_artifact
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: frontend
|
||||
run: yarn install
|
||||
- name: Run Prettier
|
||||
working-directory: frontend
|
||||
run: npm run prettify
|
||||
continue-on-error: true
|
||||
- name: Run ESLint
|
||||
working-directory: frontend
|
||||
run: npm run lint
|
||||
continue-on-error: true
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build & Push Query Service Docker Image
|
||||
shell: bash
|
||||
env:
|
||||
QUERY_SERVICE_DIRECTORY: "pkg/query-service"
|
||||
REPONAME: ${{ secrets.REPONAME }}
|
||||
QUERY_SERVICE_DOCKER_IMAGE: ${QUERY_SERVICE}
|
||||
DOCKER_TAG: ${IMG_TAG}
|
||||
run: |
|
||||
branch=${GITHUB_REF#refs/*/}
|
||||
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
|
||||
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [ ${array[1]} == "pull" ] ||[[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
|
||||
then
|
||||
source env-vars
|
||||
make build-push-query-service
|
||||
fi
|
||||
|
||||
build-and-push-flattener:
|
||||
runs-on: ubuntu-latest
|
||||
needs:
|
||||
- get-envs
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Downloading image artifact
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: env_artifact
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
id: buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build & Push Flattener Processor Docker Image
|
||||
shell: bash
|
||||
env:
|
||||
FLATTENER_DIRECTORY: "pkg/processors/flattener"
|
||||
REPONAME: ${{ secrets.REPONAME }}
|
||||
FLATTERNER_DOCKER_IMAGE: ${FLATTENER_PROCESSOR}
|
||||
DOCKER_TAG: ${IMG_TAG}
|
||||
run: |
|
||||
branch=${GITHUB_REF#refs/*/}
|
||||
array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`)
|
||||
if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [ ${array[1]} == "pull" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]]
|
||||
then
|
||||
source env-vars
|
||||
make build-push-flattener
|
||||
fi
|
||||
- uses: benjlevesque/short-sha@v1.2
|
||||
id: short-sha
|
||||
- name: Get branch name
|
||||
id: branch-name
|
||||
uses: tj-actions/branch-names@v5.1
|
||||
- name: Build and push docker image
|
||||
env:
|
||||
DOCKER_TAG: ${{ steps.short-sha.outputs.sha }}
|
||||
DOCKER_SECOND_TAG: ${{ steps.branch-name.outputs.current_branch }}
|
||||
run: make build-push-frontend
|
||||
|
14
Makefile
14
Makefile
@ -29,8 +29,15 @@ build-push-frontend:
|
||||
@echo "------------------"
|
||||
@echo "--> Building and pushing frontend docker image"
|
||||
@echo "------------------"
|
||||
ifndef DOCKER_SECOND_TAG
|
||||
@cd $(FRONTEND_DIRECTORY) && \
|
||||
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/amd64 --tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) .
|
||||
else
|
||||
@cd $(FRONTEND_DIRECTORY) && \
|
||||
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/amd64 . \
|
||||
--tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) \
|
||||
--tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_SECOND_TAG)
|
||||
endif
|
||||
|
||||
# Steps to build and push docker image of query service
|
||||
.PHONY: build-query-service-amd64 build-push-query-service
|
||||
@ -47,8 +54,15 @@ build-push-query-service:
|
||||
@echo "------------------"
|
||||
@echo "--> Building and pushing query-service docker image"
|
||||
@echo "------------------"
|
||||
ifndef DOCKER_SECOND_TAG
|
||||
@cd $(QUERY_SERVICE_DIRECTORY) && \
|
||||
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 --tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) .
|
||||
else
|
||||
@cd $(QUERY_SERVICE_DIRECTORY) && \
|
||||
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/arm64,linux/amd64 . \
|
||||
--tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_TAG) \
|
||||
--tag $(REPONAME)/$(QUERY_SERVICE_DOCKER_IMAGE):$(DOCKER_SECOND_TAG)
|
||||
endif
|
||||
|
||||
# Steps to build and push docker image of flattener
|
||||
.PHONY: build-flattener-amd64 build-push-flattener
|
||||
|
Loading…
x
Reference in New Issue
Block a user