Skip to content

Commit

Permalink
refactor(ci): switch from merge commit to head sha commit in builds (#…
Browse files Browse the repository at this point in the history
…446)

Switch from Merge commit to HEAD SHA to prevent rebuilding images that have not been modified in the current branch
---------

Signed-off-by: Nikita Korolev <[email protected]>
Co-authored-by: Ivan Mikheykin <[email protected]>
  • Loading branch information
universal-itengineer and diafour authored Oct 18, 2024
1 parent 69e4003 commit ebd6892
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/dev_module_build-on-self-hosted-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ jobs:
version: 3.37.2

- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Run lint virtualization-controller
run: |
Expand Down Expand Up @@ -177,6 +180,8 @@ jobs:
version: 3.37.2

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Run test hooks
run: |
Expand All @@ -196,6 +201,7 @@ jobs:
runs-on: [self-hosted, ci-testing]
env:
MODULES_MODULE_TAG: ${{needs.set_vars.outputs.modules_module_tag}}
WERF_VIRTUAL_MERGE: 0
steps:
- name: Print vars
run: |
Expand All @@ -208,6 +214,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Remove unwanted software
uses: ./.github/actions/remove-unwanted-software
Expand Down
22 changes: 19 additions & 3 deletions .github/workflows/dev_module_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ env:

on:
workflow_dispatch:
inputs:
pr_number:
required: false
type: number
pull_request:
types: [opened, synchronize]
types: [opened, reopened, synchronize]
push:
branches:
- main
Expand All @@ -53,8 +57,14 @@ jobs:
run: |
if [[ "${{ github.ref_name }}" == 'pre-alpha' || "${{ github.ref_name }}" == 'main' ]]; then
MODULES_MODULE_TAG="${{ github.ref_name }}"
else
elif [[ -n "${{ github.event.pull_request.number }}" ]]; then
MODULES_MODULE_TAG="pr${{ github.event.pull_request.number }}"
elif [[ -n "${{ github.event.inputs.pr_number }}" ]]; then
MODULES_MODULE_TAG="pr${{ github.event.inputs.pr_number }}"
else
echo "Cannot set MODULES_MODULE_TAG variable"
echo "Exit"
exit 1
fi
echo "MODULES_MODULE_TAG=$MODULES_MODULE_TAG" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -121,6 +131,8 @@ jobs:
version: 3.37.2

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Run lint virtualization-controller
run: |
Expand All @@ -138,7 +150,7 @@ jobs:

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Lint yaml with prettier
run: task -p lint:prettier:yaml
Expand All @@ -158,6 +170,8 @@ jobs:
version: 3.37.2

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Run test hooks
run: |
Expand All @@ -174,6 +188,7 @@ jobs:
needs: set_vars
env:
MODULES_MODULE_TAG: ${{needs.set_vars.outputs.modules_module_tag}}
WERF_VIRTUAL_MERGE: 0
steps:
- name: Print vars
run: |
Expand All @@ -186,6 +201,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Remove unwanted software
uses: ./.github/actions/remove-unwanted-software
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dev_validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Run validation "No cyrillic"
run: |
Expand All @@ -71,6 +72,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Run validation "Doc changes"
run: |
Expand All @@ -94,6 +96,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Run validation "Copyright"
run: |
Expand Down

0 comments on commit ebd6892

Please sign in to comment.