Skip to content

Commit

Permalink
refactor(ci): add build for pre-alpha, rename workflow for warmup cac…
Browse files Browse the repository at this point in the history
…he (#109)

СI improvement
---------

Signed-off-by: Nikita Korolev <[email protected]>
Co-authored-by: Ivan Mikheykin <[email protected]>
  • Loading branch information
universal-itengineer and diafour authored May 28, 2024
1 parent 82152b5 commit 2dd0301
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 34 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build main every 8 hours for dev
name: Build main, pre-alpha every 8 hours for dev

env:
MODULES_REGISTRY: ${{ vars.DEV_REGISTRY }}
Expand All @@ -18,19 +18,17 @@ defaults:
shell: bash

jobs:
build_main:
runs-on: ubuntu-latest
build_branches:
name: Build main
runs-on: ubuntu-latest
strategy:
matrix:
branch: [main, pre-alpha]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Set vars for main
run: |
MODULES_MODULE_TAG="$(echo ${{ github.ref_name }})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
ref: ${{ matrix.branch }}

- name: Remove unwanted software
uses: ./.github/actions/remove-unwanted-software
Expand All @@ -39,5 +37,9 @@ jobs:

- name: Build images
run: |
# MODULES_MODULE_TAG env is required by release-channel image.
# This image is not significant for development environments, so we use fake value for it.
echo "Warmup cache using MODULES_MODULE_TAG=dev"
export MODULES_MODULE_TAG=dev
source "$(werf ci-env github --as-file)"
werf build --repo=${MODULES_MODULE_SOURCE}/${MODULES_MODULE_NAME}
50 changes: 25 additions & 25 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
push:
branches:
- main
- pre-alpha

defaults:
run:
Expand All @@ -25,22 +26,30 @@ concurrency:
cancel-in-progress: true

jobs:
show_dev_manifest:
set_vars:
runs-on: ubuntu-latest
name: Show manifest
name: Set MODULES_MODULE_TAG
outputs:
modules_module_tag: ${{ steps.modules_module_tag.outputs.MODULES_MODULE_TAG }}
steps:
- name: Set vars for PR
if: ${{ github.ref_name != 'main' }}
- name: Set vars
id: modules_module_tag
run: |
MODULES_MODULE_TAG="$(echo pr${{github.event.pull_request.number}})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
if [[ "${{ github.ref_name }}" == 'pre-alpha' || "${{ github.ref_name }}" == 'main' ]]; then
MODULES_MODULE_TAG="${{ github.ref_name }}"
else
MODULES_MODULE_TAG="$(echo pr${{ github.event.pull_request.number }})"
fi
- name: Set vars for main
if: ${{ github.ref_name == 'main' }}
run: |
MODULES_MODULE_TAG="$(echo v0.0.0-${{ github.ref_name }})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_OUTPUT"
show_dev_manifest:
runs-on: ubuntu-latest
name: Show manifest
needs: set_vars
env:
MODULES_MODULE_TAG: ${{needs.set_vars.outputs.modules_module_tag}}
steps:
- name: Show dev config
run: |
cat << OUTER
Expand Down Expand Up @@ -146,19 +155,10 @@ jobs:
dev_setup_build:
runs-on: ubuntu-latest
name: Build and Push images
needs: set_vars
env:
MODULES_MODULE_TAG: ${{needs.set_vars.outputs.modules_module_tag}}
steps:
- name: Set vars for PR
if: ${{ github.ref_name != 'main' }}
run: |
MODULES_MODULE_TAG="$(echo pr${{github.event.pull_request.number}})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
- name: Set vars for main
if: ${{ github.ref_name == 'main' }}
run: |
MODULES_MODULE_TAG="$(echo v0.0.0-${{ github.ref_name }})"
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_ENV"
- name: Print vars
run: |
echo MODULES_REGISTRY=$MODULES_REGISTRY
Expand All @@ -180,8 +180,8 @@ jobs:

- run: |
IMAGE_SRC="$(jq -r '.Images."bundle".DockerImageName' images_tags_werf.json)"
IMAGE_DST="$(jq -r '.Images.bundle.DockerRepo' images_tags_werf.json):main"
IMAGE_DST="$(jq -r '.Images.bundle.DockerRepo' images_tags_werf.json):v0.0.0-main"
echo "✨ Bundle image : Pushing ${IMAGE_SRC} to ${IMAGE_DST}"
crane copy ${IMAGE_SRC} ${IMAGE_DST}
if: ${{ github.ref_name == 'main' }}
name: Bundle image tag main
name: Push legacy module tag v0.0.0-main

0 comments on commit 2dd0301

Please sign in to comment.