mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 16:18:59 +08:00
Merge pull request #593 from ybettan/push-workflow-pr
ci: adding 'push' workflow
This commit is contained in:
commit
9808c03d6d
178
.github/workflows/push.yaml
vendored
178
.github/workflows/push.yaml
vendored
@ -1,172 +1,72 @@
|
|||||||
name: push-pipeline
|
name: push
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
paths:
|
||||||
- main
|
- 'pkg/query-service/**'
|
||||||
- ^v[0-9]*.[0-9]*.x$
|
- 'frontend/**'
|
||||||
tags:
|
|
||||||
- "*"
|
|
||||||
# pull_request:
|
|
||||||
# branches:
|
|
||||||
# - main
|
|
||||||
# - v*
|
|
||||||
# paths:
|
|
||||||
# - 'pkg/**'
|
|
||||||
# - 'frontend/**'
|
|
||||||
jobs:
|
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
|
image-build-and-push-query-service:
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: env_artifact
|
|
||||||
path: env-vars
|
|
||||||
|
|
||||||
build-and-push-frontend:
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- get-envs
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
- name: Set up QEMU
|
||||||
- name: Downloading image artifact
|
uses: docker/setup-qemu-action@v1
|
||||||
uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: env_artifact
|
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- uses: benjlevesque/short-sha@v1.2
|
||||||
- name: Build & Push Frontend Docker Image
|
id: short-sha
|
||||||
shell: bash
|
- name: Get branch name
|
||||||
|
id: branch-name
|
||||||
|
uses: tj-actions/branch-names@v5.1
|
||||||
|
- name: Build and push docker image
|
||||||
env:
|
env:
|
||||||
FRONTEND_DIRECTORY: "frontend"
|
DOCKER_TAG: ${{ steps.short-sha.outputs.sha }}
|
||||||
REPONAME: ${{ secrets.REPONAME }}
|
DOCKER_SECOND_TAG: ${{ steps.branch-name.outputs.current_branch }}
|
||||||
FRONTEND_DOCKER_IMAGE: ${FRONTEND_IMAGE}
|
run: make build-push-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-frontend
|
|
||||||
fi
|
|
||||||
|
|
||||||
build-and-push-query-service:
|
image-build-and-push-frontend:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
|
||||||
- get-envs
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
- name: Install dependencies
|
||||||
- name: Downloading image artifact
|
working-directory: frontend
|
||||||
uses: actions/download-artifact@v2
|
run: yarn install
|
||||||
with:
|
- name: Run Prettier
|
||||||
name: env_artifact
|
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
|
- name: Set up Docker Buildx
|
||||||
id: buildx
|
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
- uses: benjlevesque/short-sha@v1.2
|
||||||
- name: Build & Push Query Service Docker Image
|
id: short-sha
|
||||||
shell: bash
|
- name: Get branch name
|
||||||
|
id: branch-name
|
||||||
|
uses: tj-actions/branch-names@v5.1
|
||||||
|
- name: Build and push docker image
|
||||||
env:
|
env:
|
||||||
QUERY_SERVICE_DIRECTORY: "pkg/query-service"
|
DOCKER_TAG: ${{ steps.short-sha.outputs.sha }}
|
||||||
REPONAME: ${{ secrets.REPONAME }}
|
DOCKER_SECOND_TAG: ${{ steps.branch-name.outputs.current_branch }}
|
||||||
QUERY_SERVICE_DOCKER_IMAGE: ${QUERY_SERVICE}
|
run: make build-push-frontend
|
||||||
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
|
|
||||||
|
14
Makefile
14
Makefile
@ -29,8 +29,15 @@ build-push-frontend:
|
|||||||
@echo "------------------"
|
@echo "------------------"
|
||||||
@echo "--> Building and pushing frontend docker image"
|
@echo "--> Building and pushing frontend docker image"
|
||||||
@echo "------------------"
|
@echo "------------------"
|
||||||
|
ifndef DOCKER_SECOND_TAG
|
||||||
@cd $(FRONTEND_DIRECTORY) && \
|
@cd $(FRONTEND_DIRECTORY) && \
|
||||||
docker buildx build --file Dockerfile --progress plane --no-cache --push --platform linux/amd64 --tag $(REPONAME)/$(FRONTEND_DOCKER_IMAGE):$(DOCKER_TAG) .
|
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
|
# Steps to build and push docker image of query service
|
||||||
.PHONY: build-query-service-amd64 build-push-query-service
|
.PHONY: build-query-service-amd64 build-push-query-service
|
||||||
@ -47,8 +54,15 @@ build-push-query-service:
|
|||||||
@echo "------------------"
|
@echo "------------------"
|
||||||
@echo "--> Building and pushing query-service docker image"
|
@echo "--> Building and pushing query-service docker image"
|
||||||
@echo "------------------"
|
@echo "------------------"
|
||||||
|
ifndef DOCKER_SECOND_TAG
|
||||||
@cd $(QUERY_SERVICE_DIRECTORY) && \
|
@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) .
|
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
|
# Steps to build and push docker image of flattener
|
||||||
.PHONY: build-flattener-amd64 build-push-flattener
|
.PHONY: build-flattener-amd64 build-push-flattener
|
||||||
|
Loading…
x
Reference in New Issue
Block a user