From ff569c78454b8c03072e27e19652755c4e60a065 Mon Sep 17 00:00:00 2001 From: Aleksandr Zimin Date: Thu, 4 Jan 2024 22:37:14 +0300 Subject: [PATCH 1/2] Add build for main Signed-off-by: Aleksandr Zimin --- .github/workflows/build_dev.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_dev.yml b/.github/workflows/build_dev.yml index b0255cf7..6c05fcb5 100644 --- a/.github/workflows/build_dev.yml +++ b/.github/workflows/build_dev.yml @@ -1,9 +1,15 @@ +name: Build and push for dev + on: pull_request: + push: + branches: + - main jobs: dev_setup_build: runs-on: ubuntu-latest + name: Build and Push images env: MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} CI_COMMIT_REF_NAME: ${{ github.ref_name }} @@ -11,18 +17,26 @@ jobs: MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }} MODULES_REGISTRY_LOGIN: ${{ secrets.DEV_MODULES_REGISTRY_LOGIN }} MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} - name: Build and Push images steps: - - run: | + - name: Set vars for PR + if: ${{ github.ref_name != 'main' }} + run: | MODULES_MODULE_TAG="$(echo pr${{ github.ref_name }} | sed 's/\/.*//g')" - echo $MODULES_REGISTRY - echo $CI_COMMIT_REF_NAME echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV" - echo $MODULES_MODULE_NAME - echo $MODULES_MODULE_SOURCE - echo $MODULES_MODULE_TAG shell: bash - name: Show vars + - name: Set vars for main + if: ${{ github.ref_name == 'main' }} + run: | + echo "MODULES_MODULE_TAG=${{ github.ref_name }}" >> "$GITHUB_ENV" + shell: bash + - name: Show vars + run: | + echo MODULES_REGISTRY=$MODULES_REGISTRY + echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME + echo MODULES_MODULE_NAME=$MODULES_MODULE_NAME + echo MODULES_MODULE_SOURCE=$MODULES_MODULE_SOURCE + echo MODULES_MODULE_TAG=$MODULES_MODULE_TAG + shell: bash - uses: actions/checkout@v4 - uses: deckhouse/modules-actions/setup@v1 From 0814240d14744837c014cc4568fb19e3c76a1f44 Mon Sep 17 00:00:00 2001 From: Aleksandr Zimin Date: Thu, 4 Jan 2024 23:28:17 +0300 Subject: [PATCH 2/2] Add deploy dev Signed-off-by: Aleksandr Zimin --- .github/workflows/build_dev.yml | 17 +++++----- .github/workflows/deploy_dev.yml | 52 +++++++++++++++++++++++++++++++ .github/workflows/deploy_prod.yml | 6 ++-- 3 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/deploy_dev.yml diff --git a/.github/workflows/build_dev.yml b/.github/workflows/build_dev.yml index 6c05fcb5..101ae9af 100644 --- a/.github/workflows/build_dev.yml +++ b/.github/workflows/build_dev.yml @@ -1,5 +1,13 @@ name: Build and push for dev +env: + MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} + CI_COMMIT_REF_NAME: ${{ github.ref_name }} + MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }} + MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }} + MODULES_REGISTRY_LOGIN: ${{ secrets.DEV_MODULES_REGISTRY_LOGIN }} + MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} + on: pull_request: push: @@ -10,13 +18,6 @@ jobs: dev_setup_build: runs-on: ubuntu-latest name: Build and Push images - env: - MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} - CI_COMMIT_REF_NAME: ${{ github.ref_name }} - MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }} - MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }} - MODULES_REGISTRY_LOGIN: ${{ secrets.DEV_MODULES_REGISTRY_LOGIN }} - MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} steps: - name: Set vars for PR if: ${{ github.ref_name != 'main' }} @@ -29,7 +30,7 @@ jobs: run: | echo "MODULES_MODULE_TAG=${{ github.ref_name }}" >> "$GITHUB_ENV" shell: bash - - name: Show vars + - name: Print vars run: | echo MODULES_REGISTRY=$MODULES_REGISTRY echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME diff --git a/.github/workflows/deploy_dev.yml b/.github/workflows/deploy_dev.yml new file mode 100644 index 00000000..44dede70 --- /dev/null +++ b/.github/workflows/deploy_dev.yml @@ -0,0 +1,52 @@ +name: Deploy Dev + +env: + MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }} + CI_COMMIT_REF_NAME: ${{ github.event.inputs.tag }} + MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }} + MODULES_MODULE_SOURCE: ${{ vars.DEV_MODULE_SOURCE }} + MODULES_REGISTRY_LOGIN: ${{ secrets.DEV_MODULES_REGISTRY_LOGIN }} + MODULES_REGISTRY_PASSWORD: ${{ secrets.DEV_MODULES_REGISTRY_PASSWORD }} + RELEASE_CHANNEL: ${{ github.event.inputs.channel }} + MODULES_MODULE_TAG: ${{ github.event.inputs.tag }} + +on: + workflow_dispatch: + inputs: + channel: + description: "Select release channel" + type: choice + default: alpha + options: + - "alpha" + - "beta" + - "early-access" + - "stable" + - "rock-solid" + + tag: + description: "The module's tag, which must include the -dev postfix. For example: v1.21.1-dev" + type: string + required: true + +jobs: + deploy-dev: + runs-on: ubuntu-latest + name: Deploy dev + steps: + - name: PRINT VARS + run: | + echo MODULES_REGISTRY=$MODULES_REGISTRY + echo MODULE_SOURCE_NAME=$MODULE_SOURCE_NAME + echo CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME + echo MODULES_MODULE_NAME=$MODULES_MODULE_NAME + echo RELEASE_CHANNEL=$RELEASE_CHANNEL + echo MODULES_MODULE_TAG=$MODULES_MODULE_TAG + shell: bash + - name: Validation for tag + run: | + echo ${{ github.event.inputs.tag }} | grep -P '^v\d+\.\d+\.\d+-dev$' + shell: bash + + - uses: actions/checkout@v4 + - uses: deckhouse/modules-actions/setup@v1 diff --git a/.github/workflows/deploy_prod.yml b/.github/workflows/deploy_prod.yml index 5a3d9352..ff842fc1 100644 --- a/.github/workflows/deploy_prod.yml +++ b/.github/workflows/deploy_prod.yml @@ -5,7 +5,7 @@ env: MODULE_SOURCE_NAME: ${{ vars.PROD_MODULE_SOURCE_NAME }} CI_COMMIT_REF_NAME: ${{ github.ref_name }} MODULES_MODULE_NAME: ${{ vars.MODULE_NAME }} - RELEASE_CHANNEL: ${{ github.event.inputs.version }} + RELEASE_CHANNEL: ${{ github.event.inputs.channel }} MODULES_REGISTRY_LOGIN: ${{ secrets.PROD_MODULES_REGISTRY_LOGIN }} MODULES_REGISTRY_PASSWORD: ${{ secrets.PROD_MODULES_REGISTRY_PASSWORD }} MODULES_MODULE_TAG: ${{ github.event.inputs.tag }} @@ -13,8 +13,8 @@ env: on: workflow_dispatch: inputs: - version: - description: "Select version" + channel: + description: "Select release channel" type: choice default: alpha options: