Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dev-metadata-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ branches-template:
- feature/*: "{{ref-name}}-{{timestamp}}, {{ref-name}}-{{short-sha}}, {{short-sha}}"
- hotfix/*: "{{ref-name}}-{{timestamp}}, {{ref-name}}-{{short-sha}}, {{short-sha}}"
- bugfix/*: "{{ref-name}}-{{timestamp}}, {{ref-name}}-{{short-sha}}, {{short-sha}}"
- chore/*: "{{ref-name}}-{{timestamp}}, {{ref-name}}-{{short-sha}}, {{short-sha}}"
distribution-tags:
- main: "main"
136 changes: 72 additions & 64 deletions .github/workflows/docker-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Docker with Matrix Strategy

on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
types: [opened, synchronize, reopened]
branches:
- main
workflow_dispatch:
inputs:
tags:
Expand All @@ -29,34 +29,34 @@ jobs:
components: ${{ steps.load_component.outputs.components }}
platforms: ${{ steps.load_component.outputs.platforms }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Checkout Repository
uses: actions/checkout@v4

- name: Load Docker Configuration
id: load_component
shell: bash
run: |
verify=$(cat "$GITHUB_WORKSPACE/.github/docker-dev-config.json" | jq '
def verify_structure:
.components as $components
| .platforms as $platforms
| ($components | type == "array")
and (all($components[]; has("name") and has("file") and has("context")))
and ($platforms | type == "string");
verify_structure
| if . then true else false end
')
if [ "${verify}" == "true" ]; then
echo "✅ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is valid"
components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/docker-dev-config.json")
platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/docker-dev-config.json")
else
echo "❗ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is invalid"
echo "❗ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is invalid" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "components=${components}" >> "$GITHUB_OUTPUT"
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"
- name: Load Docker Configuration
id: load_component
shell: bash
run: |
verify=$(cat "$GITHUB_WORKSPACE/.github/docker-dev-config.json" | jq '
def verify_structure:
.components as $components
| .platforms as $platforms
| ($components | type == "array")
and (all($components[]; has("name") and has("file") and has("context")))
and ($platforms | type == "string");
verify_structure
| if . then true else false end
')
if [ "${verify}" == "true" ]; then
echo "✅ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is valid"
components=$(jq -c ".components" "$GITHUB_WORKSPACE/.github/docker-dev-config.json")
platforms=$(jq -c ".platforms" "$GITHUB_WORKSPACE/.github/docker-dev-config.json")
else
echo "❗ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is invalid"
echo "❗ $GITHUB_WORKSPACE/.github/docker-dev-config.json file is invalid" >> $GITHUB_STEP_SUMMARY
exit 1
fi
echo "components=${components}" >> "$GITHUB_OUTPUT"
echo "platforms=${platforms}" >> "$GITHUB_OUTPUT"

perform-version:
runs-on: ubuntu-latest
Expand All @@ -65,32 +65,32 @@ jobs:
metadata: "${{ steps.metadata.outputs.result }}"
tags: "${{ steps.prepare_tags.outputs.tags }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Create name
uses: netcracker/qubership-workflow-hub/actions/metadata-action@main
id: metadata
with:
configuration-path: .github/dev-metadata-config.yml
short-sha: 11
- name: Create name
uses: netcracker/qubership-workflow-hub/actions/metadata-action@v1.0.0
id: metadata
with:
configuration-path: .github/dev-metadata-config.yml
short-sha: 11

- name: Echo metadata
run: echo "Metadata result ${{ steps.metadata.outputs.result }}" >> $GITHUB_STEP_SUMMARY
- name: Echo metadata
run: echo "Metadata result ${{ steps.metadata.outputs.result }}" >> $GITHUB_STEP_SUMMARY

- name: Prepare tags
id: prepare_tags
run: |
BASE_TAG="${{ steps.metadata.outputs.result }}"
EXTRA_TAG="${{ github.event.inputs.tags }}"
if [ -n "$EXTRA_TAG" ]; then
TAGS="${BASE_TAG}, ${EXTRA_TAG}"
else
TAGS="${BASE_TAG}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "tags: ${TAGS}" >> $GITHUB_STEP_SUMMARY
echo "github.head_ref = ${{ github.head_ref }}"
- name: Prepare tags
id: prepare_tags
run: |
BASE_TAG="${{ steps.metadata.outputs.result }}"
EXTRA_TAG="${{ github.event.inputs.tags }}"
if [ -n "$EXTRA_TAG" ]; then
TAGS="${BASE_TAG}, ${EXTRA_TAG}"
else
TAGS="${BASE_TAG}"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "tags: ${TAGS}" >> $GITHUB_STEP_SUMMARY
echo "github.head_ref = ${{ github.head_ref }}"
build:
name: "Build Docker Images"
needs: [load_config, perform-version]
Expand All @@ -100,14 +100,22 @@ jobs:
matrix:
component: ${{ fromJson(needs.load_config.outputs.components) }}
steps:
- name: Docker
uses: netcracker/qubership-workflow-hub/actions/docker-action@main
with:
ref: ${{ github.ref }}
dry-run: ${{ inputs.dry-run }}
download-artifact: false
component: ${{ toJson(matrix.component) }}
platforms: ${{ needs.load_config.outputs.platforms }}
tags: ${{ needs.perform-version.outputs.tags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Docker
uses: netcracker/qubership-workflow-hub/actions/docker-action@v1.0.0
with:
ref: ${{ github.ref }}
dry-run: ${{ inputs.dry-run }}
download-artifact: false
component: ${{ toJson(matrix.component) }}
platforms: ${{ needs.load_config.outputs.platforms }}
tags: ${{ needs.perform-version.outputs.tags }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Job to ensure completion is only signaled AFTER all matrix jobs finish
notify-completion:
needs: [build]
runs-on: ubuntu-latest
steps:
- run: echo "All matrix jobs completed"

Loading
Loading