From a0cdafa993e4d7cfe96e5881af5992710a1c76de Mon Sep 17 00:00:00 2001 From: Mohmn Date: Sat, 17 Feb 2024 03:13:06 +0530 Subject: [PATCH] feat: build multiple docker images for multiple envs --- .../deploy-main-channel-to-prod.yaml | 2 +- .github/workflows/dev-build-release.yaml | 41 +++++++++++-------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy-main-channel-to-prod.yaml b/.github/workflows/deploy-main-channel-to-prod.yaml index a54136ec5..54f136323 100644 --- a/.github/workflows/deploy-main-channel-to-prod.yaml +++ b/.github/workflows/deploy-main-channel-to-prod.yaml @@ -28,7 +28,7 @@ jobs: - name: Use Node.js 18.x uses: actions/setup-node@v1 with: - node-version: '18.x' + node-version: '20.x' - name: get-npm-version id: package-version uses: martinbeentjes/npm-get-version-action@master diff --git a/.github/workflows/dev-build-release.yaml b/.github/workflows/dev-build-release.yaml index a5086a9ff..0fea5cbcb 100644 --- a/.github/workflows/dev-build-release.yaml +++ b/.github/workflows/dev-build-release.yaml @@ -50,38 +50,47 @@ jobs: working-directory: ${{ env.project-directory }} env: NODE_ENV: production - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + - id: export_bumped_version + run: | + export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}" + echo "bumped_version=${BUMPED_VERSION}" >> $GITHUB_OUTPUT + outputs: + bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }} + # todo add test image here + # since test api is throwing some error that is why i excluded that + build-and-push-docker: + name: Build and Push Docker Images + runs-on: ubuntu-latest + needs: release + strategy: + matrix: + include: + - dockerfile: ./Dockerfile-dev + image_name: greenstand/${{ github.event.repository.name }}-dev:${{ needs.release.outputs.bumped_version }} + - dockerfile: ./Dockerfile + image_name: greenstand/${{ github.event.repository.name }}:${{ needs.release.outputs.bumped_version }} + steps: + - uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build snapshot and push on merge - id: docker_build_release + - name: Build and push uses: docker/build-push-action@v2 with: context: ./ - file: ./Dockerfile-dev + file: ${{ matrix.dockerfile }} push: true - tags: greenstand/${{ github.event.repository.name }}-dev:${{ steps.package-version.outputs.current-version }} - - - id: export_bumped_version - run: | - export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}" - echo "bumped_version=${BUMPED_VERSION}" >> $GITHUB_OUTPUT - outputs: - bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }} + tags: ${{ matrix.image_name }} deploy: name: Deploy to dev runs-on: ubuntu-latest - needs: release + needs: build-and-push-docker steps: - uses: actions/checkout@v2 with: