diff --git a/.github/workflows/README.md b/.github/workflows/README.md new file mode 100644 index 0000000000..2535ecc9bb --- /dev/null +++ b/.github/workflows/README.md @@ -0,0 +1,25 @@ +To Run github workflow, few environment varibale needs to added in github secrets + +#### Tunables + + + + + + + + + + + + + + + + + + + + + + diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000000..7298787d8a --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,70 @@ +name: build-pipeline +on: + pull_request: + branches: + - main + - v* + paths: + - 'pkg/**' + - 'frontend/**' + +jobs: + get_filters: + runs-on: ubuntu-latest + # Set job outputs to values from filter step + outputs: + frontend: ${{ steps.filter.outputs.frontend }} + query-service: ${{ steps.filter.outputs.query-service }} + flattener: ${{ steps.filter.outputs.flattener }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + frontend: + - 'frontend/**' + query-service: + - 'pkg/query-service/**' + flattener: + - 'pkg/processors/flattener/**' + + build-frontend: + runs-on: ubuntu-latest + needs: + - get_filters + if: ${{ needs.get_filters.outputs.frontend == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build frontend docker image + shell: bash + run: | + cd frontend + docker build . -f Dockerfile + build-query-service: + runs-on: ubuntu-latest + needs: + - get_filters + if: ${{ needs.get_filters.outputs.query-service == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build query-service image + shell: bash + run: | + cd pkg/query-service + docker build . -f Dockerfile + build-flattener: + runs-on: ubuntu-latest + needs: + - get_filters + if: ${{ needs.get_filters.outputs.flattener == 'true' }} + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build flattener docker image + shell: bash + run: | + cd pkg/processors/flattener + docker build . -f Dockerfile diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 0000000000..15e6ee7191 --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,128 @@ +name: push-pipeline +on: + push: + branches: + - main + - ^v[0-9]*.[0-9]*.x$ + tags: + - "*" + +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/*/} + else + echo "non tag build" + img_tag="latest" + fi + # This is a condition where image tag looks like "pull/" 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: + runs-on: ubuntu-latest + needs: + - get-envs + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build frontend docker image + shell: bash + run: | + cd frontend + docker build . -f Dockerfile + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push frontend docker image + shell: bash + run: | + branch=${GITHUB_REF#refs/*/} + array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`) + if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]] + then + source env-vars + docker push ${{ secrets.REPONAME }}/${FRONTEND_IMAGE}:${IMG_TAG} + fi + + build-and-push-query-service: + runs-on: ubuntu-latest + needs: + - get-envs + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build query-service image + shell: bash + run: | + cd pkg/query-service + docker build . -f Dockerfile + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push query service docker image + shell: bash + run: | + branch=${GITHUB_REF#refs/*/} + array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`) + if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]] + then + source env-vars + docker push ${{ secrets.REPONAME }}/${QUERY_SERVICE}:${IMG_TAG} + fi + + build-and-push-flattener: + runs-on: ubuntu-latest + needs: + - get-envs + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Build flattener docker image + shell: bash + run: | + cd pkg/processors/flattener + docker build . -f Dockerfile + - name: Build flattener processor docker image + shell: bash + run: | + cd pkg/query-service + docker build . -f Dockerfile + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push flattener processor docker image + shell: bash + run: | + branch=${GITHUB_REF#refs/*/} + array=(`echo ${GITHUB_REF} | sed 's/\//\n/g'`) + if [ $branch == "main" ] || [ ${array[1]} == "tags" ] || [[ $branch =~ ^v[0-9]*.[0-9]*.x$ ]] + then + source env-vars + docker push ${{ secrets.REPONAME }}/${FLATTENER_PROCESSOR}:${IMG_TAG} + fi \ No newline at end of file diff --git a/frontend/yarn.lock b/frontend/yarn.lock index edc1d1c91f..98cc2d8949 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -14277,4 +14277,4 @@ yargs@~3.10.0: yocto-queue@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" - integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== \ No newline at end of file
Variables Description Example
REPONAME Provide the DockerHub user/organisation name of the image. signoz
DOCKERHUB_USERNAME Docker hub username signoz
DOCKERHUB_TOKEN Docker hub password/token with push permission ****