From 636976bcd6e9956c5bc2975efec438bbf13babb8 Mon Sep 17 00:00:00 2001 From: ascariandrea Date: Mon, 7 Nov 2022 17:45:54 +0100 Subject: [PATCH 1/2] ci: build both yt:backend and tk:backend with docker as CI step --- .github/workflows/master_release.yml | 16 +++++++++++++++- .github/workflows/tk_pull_request.yml | 12 ++++++++++++ ...trex_pull_request.yml => yt_pull_request.yml} | 10 ++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) rename .github/workflows/{yttrex_pull_request.yml => yt_pull_request.yml} (79%) diff --git a/.github/workflows/master_release.yml b/.github/workflows/master_release.yml index b9334c4ac..18e04b314 100644 --- a/.github/workflows/master_release.yml +++ b/.github/workflows/master_release.yml @@ -9,7 +9,6 @@ permissions: contents: write jobs: - build: name: Build runs-on: ubuntu-latest @@ -155,6 +154,21 @@ jobs: git config --global user.name "Team - Tracking Exposed" yarn release-it --ci + # - name: Push image + # run: | + # IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$YT_IMAGE_NAME + + # # Strip git ref prefix from version + # VERSION=$(yarn release-it --no-github.release --release-version) + # # Strip "v" prefix from tag name + # [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # # Use Docker `latest` tag convention + # [ "$VERSION" == "master" ] && VERSION=latest + # echo IMAGE_ID=$IMAGE_ID + # echo VERSION=$VERSION + # docker tag $YT_IMAGE_NAME $IMAGE_ID:$VERSION + # docker push $IMAGE_ID:$VERSION + - name: Build Dashboard env: DOTENV_CONFIG_PATH: .env diff --git a/.github/workflows/tk_pull_request.yml b/.github/workflows/tk_pull_request.yml index 73b756bac..66b27b797 100644 --- a/.github/workflows/tk_pull_request.yml +++ b/.github/workflows/tk_pull_request.yml @@ -15,6 +15,9 @@ on: - "packages/**" - "platforms/tktrex/**" +env: + TK_IMAGE_NAME: tk-backend + jobs: pull_request: runs-on: ubuntu-latest @@ -65,3 +68,12 @@ jobs: yarn pm2 start platforms/tktrex/backend/ecosystem.config.js --env test yarn tk:backend test --runInBand --ci --forceExit yarn pm2 stop all + + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Build TK Backend image + run: docker build . --file Dockerfile.tkbackend --tag $TK_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + + diff --git a/.github/workflows/yttrex_pull_request.yml b/.github/workflows/yt_pull_request.yml similarity index 79% rename from .github/workflows/yttrex_pull_request.yml rename to .github/workflows/yt_pull_request.yml index aec47f8a8..214c3c220 100644 --- a/.github/workflows/yttrex_pull_request.yml +++ b/.github/workflows/yt_pull_request.yml @@ -15,6 +15,9 @@ on: - "shared/**" - "platforms/yttrex/**" +env: + YT_IMAGE_NAME: yt-backend + jobs: pull_request: runs-on: ubuntu-latest @@ -71,3 +74,10 @@ jobs: yarn yt:backend test --runInBand --forceExit --ci yarn pm2 stop all + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Build TK Backend image + run: docker build . --file Dockerfile.ytbackend --tag $YT_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + From 16af54fd910ff25fa05b02b472bc8273a33a0756 Mon Sep 17 00:00:00 2001 From: ascariandrea Date: Tue, 15 Nov 2022 09:51:45 +0100 Subject: [PATCH 2/2] ci: push backend docker images on release workflow run --- .github/workflows/gh_release.yml | 41 ++++++++++++++++++++++++++++ .github/workflows/master_release.yml | 15 ---------- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/gh_release.yml b/.github/workflows/gh_release.yml index 81aabd183..cf1f7c712 100644 --- a/.github/workflows/gh_release.yml +++ b/.github/workflows/gh_release.yml @@ -6,6 +6,9 @@ on: ref: description: 'The commit to checkout (on master)' required: true +env: + YT_IMAGE_NAME: yt-backend + TK_IMAGE_NAME: tk-backend jobs: build: @@ -54,6 +57,44 @@ jobs: yarn guardoni build:app yarn ycai build + docker_backends: + steps: + - name: Log in to registry + # This is where you will update the personal access token to GITHUB_TOKEN + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + + - name: Build & Push TK Backend image + run: | + VERSION=${{ steps.version.outputs.version }} + TK_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$TK_IMAGE_NAME + echo $IMAGE_ID + docker build . --file Dockerfile.tkbackend --tag $TK_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $TK_IMAGE_NAME $TK_IMAGE_ID:$VERSION + docker push $TK_IMAGE_ID:$VERSION + + - name: Build & Push YT Backend image + run: | + VERSION=${{ steps.version.outputs.version }} + YT_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$YT_IMAGE_NAME + echo $IMAGE_ID + docker build . --file Dockerfile.ytbackend --tag $YT_IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}" + + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $YT_IMAGE_NAME $YT_IMAGE_ID:$VERSION + docker push $YT_IMAGE_ID:$VERSION + guardoni_build: name: Guardoni build needs: [build] diff --git a/.github/workflows/master_release.yml b/.github/workflows/master_release.yml index 18e04b314..40e4a51e0 100644 --- a/.github/workflows/master_release.yml +++ b/.github/workflows/master_release.yml @@ -154,21 +154,6 @@ jobs: git config --global user.name "Team - Tracking Exposed" yarn release-it --ci - # - name: Push image - # run: | - # IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$YT_IMAGE_NAME - - # # Strip git ref prefix from version - # VERSION=$(yarn release-it --no-github.release --release-version) - # # Strip "v" prefix from tag name - # [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') - # # Use Docker `latest` tag convention - # [ "$VERSION" == "master" ] && VERSION=latest - # echo IMAGE_ID=$IMAGE_ID - # echo VERSION=$VERSION - # docker tag $YT_IMAGE_NAME $IMAGE_ID:$VERSION - # docker push $IMAGE_ID:$VERSION - - name: Build Dashboard env: DOTENV_CONFIG_PATH: .env