Skip to content

Commit

Permalink
[CI] add build for main and deploy for dev (#3)
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
AleksZimin authored Jan 4, 2024
1 parent 303114a commit b658754
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 17 deletions.
43 changes: 29 additions & 14 deletions .github/workflows/build_dev.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
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:
branches:
- main

jobs:
dev_setup_build:
runs-on: ubuntu-latest
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 }}
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: Print 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
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions .github/workflows/deploy_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ 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 }}

on:
workflow_dispatch:
inputs:
version:
description: "Select version"
channel:
description: "Select release channel"
type: choice
default: alpha
options:
Expand Down

0 comments on commit b658754

Please sign in to comment.