Skip to content

refactor: add names

refactor: add names #1

Workflow file for this run

name: Pull Request

Check failure on line 1 in .github/workflows/pull-request.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/pull-request.yml

Invalid workflow file

(Line: 410, Col: 17): Unrecognized named-value: 'source-artifact-name'. Located at position 1 within expression: source-artifact-name, (Line: 428, Col: 17): Unrecognized named-value: 'source-artifact-name'. Located at position 1 within expression: source-artifact-name, (Line: 466, Col: 17): Unrecognized named-value: 'source-artifact-name'. Located at position 1 within expression: source-artifact-name, (Line: 489, Col: 17): Unrecognized named-value: 'source-artifact-name'. Located at position 1 within expression: source-artifact-name, (Line: 510, Col: 17): Unrecognized named-value: 'source-artifact-name'. Located at position 1 within expression: source-artifact-name
on:
workflow_call:
secrets:
registry-password:
description: 'Password or token for registry login'
required: true
outputs:
version:
description: 'Detected or calculated version'
value: ${{ jobs.prepare.outputs.version }}
inputs:
previous-version:
description: 'The strategy to detect the previous version: auto, from-tag, from-file or manual'
required: false
default: 'auto'
type: string
next-version:
description: 'The strategy to calculate the next version: auto, semantic, from-file, increment or manual'
required: false
default: 'auto'
type: string
output-format:
description: 'The output format of the next version'
required: false
default: '{{.Major}}.{{.Minor}}.{{.Patch}}-pull-request'
type: string
version-file:
description: 'Set version in file named as input'
required: false
type: string
version-makefile:
description: 'Set version in makefile named as input'
required: false
type: string
version-justfile:
description: 'Set version in justfile named as input'
required: false
type: string
version-package:
description: 'Set version in package json named as input'
required: false
type: string
version-package-lock:
description: 'Set version in package lock named as input'
required: false
type: string
version-script:
description: 'Set version in script named as input'
required: false
type: string
version-chart:
description: 'Set version in chart named as input'
required: false
type: string
registry-image:
description: 'Container registry + image prefix (e.g. ghcr.io/org/repo)'
required: false
type: string
bake-file:
description: 'The bake file'
required: false
type: string
default: 'docker-bake.hcl'
bake-target:
description: 'Target name for `docker buildx bake`'
required: false
type: string
default: 'build'
meta-tags:
description: 'The tags to add to the image'
required: false
type: string
meta-labels:
description: 'The labels to add to the image'
required: false
type: string
registry-username:
description: 'Username for registry login'
required: true
type: string
runner-default:
description: 'Default runner'
required: false
type: string
default: 'ubuntu-22.04'
runner-build-arm64:
description: 'Runner for arm64 builds'
required: false
type: string
default: 'ubuntu-22.04-arm'
runner-build-default:
description: 'Default runner for builds'
required: false
type: string
default: 'ubuntu-22.04'
registry:
description: 'Docker registry domain'
required: false
type: string
default: 'ghcr.io'
free-disk-space:
description: 'Free disk space before build'
required: false
default: false
type: boolean
prepare-command:
description: 'The command to run for preparing the build'
required: false
type: string
lint-command:
description: 'The command to run for linting'
required: false
type: string
checks-command:
description: 'The command to run for checks'
required: false
type: string
just-install:
description: 'Install just'
required: false
default: false
type: boolean
just-version:
description: 'The version of just to install'
required: false
default: '1.35.0'
type: string
test-command:
description: 'The command to run for testing'
required: false
type: string
test-artifact-name:
description: 'Name of the artifact to upload for test command'
required: false
type: string
test-artifact-path:
description: 'Path to the artifact to upload for test command'
required: false
type: string
test-artifact-overwrite:
description: 'Whether to overwrite the artifact if it already exists for test command'
required: false
type: boolean
default: false
test-artifact-if-no-files-found:
description: 'Action to take if no files are found to upload for test command'
required: false
type: string
default: 'warn'
test-artifact-retention-days:
description: 'Number of days to retain the artifact for test command'
required: false
type: number
default: 30
test-unit-command:
description: 'The command to run for unit testing'
required: false
type: string
test-unit-artifact-name:
description: 'Name of the artifact to upload for unit test command'
required: false
type: string
test-unit-artifact-path:
description: 'Path to the artifact to upload for unit test command'
required: false
type: string
test-unit-artifact-overwrite:
description: 'Whether to overwrite the artifact if it already exists for unit test command'
required: false
type: boolean
default: false
test-unit-if-no-files-found:
description: 'Action to take if no files are found to upload for unit test command'
required: false
type: string
default: 'warn'
test-unit-retention-days:
description: 'Number of days to retain the artifact for unit test command'
required: false
type: number
default: 30
test-integration-command:
description: 'The command to run for integration testing'
required: false
type: string
test-integration-artifact-name:
description: 'Name of the artifact to upload for integration test command'
required: false
type: string
test-integration-artifact-path:
description: 'Path to the artifact to upload for integration test command'
required: false
type: string
test-integration-artifact-overwrite:
description: 'Whether to overwrite the artifact if it already exists for integration test command'
required: false
type: boolean
default: false
test-integration-if-no-files-found:
description: 'Action to take if no files are found to upload for integration test command'
required: false
type: string
default: 'warn'
test-integration-retention-days:
description: 'Number of days to retain the artifact for integration test command'
required: false
type: number
default: 30
test-e2e-command:
description: 'The command to run for end-to-end testing'
required: false
type: string
test-e2e-artifact-name:
description: 'Name of the artifact to upload for e2e test command'
required: false
type: string
test-e2e-artifact-path:
description: 'Path to the artifact to upload for e2e test command'
required: false
type: string
test-e2e-artifact-overwrite:
description: 'Whether to overwrite the artifact if it already exists for e2e test command'
required: false
type: boolean
default: false
test-e2e-if-no-files-found:
description: 'Action to take if no files are found to upload for e2e test command'
required: false
type: string
default: 'warn'
test-e2e-retention-days:
description: 'Number of days to retain the artifact for e2e test command'
required: false
type: number
default: 30
test-coverage-command:
description: 'The command to run for test coverage'
required: false
type: string
test-coverage-artifact-name:
description: 'Name of the artifact to upload for test coverage command'
required: false
type: string
test-coverage-artifact-path:
description: 'Path to the artifact to upload for test coverage command'
required: false
type: string
test-coverage-artifact-overwrite:
description: 'Whether to overwrite the artifact if it already exists for test coverage command'
required: false
type: boolean
default: false
test-coverage-if-no-files-found:
description: 'Action to take if no files are found to upload for test coverage command'
required: false
type: string
default: 'warn'
test-coverage-retention-days:
description: 'Number of days to retain the artifact for test coverage command'
required: false
type: number
default: 30
source-artifact-name:
description: 'Name of the artifact to upload and download for source code'
required: false
type: string
default: 'source-code'
permissions:
contents: read
packages: write
jobs:
prepare:
name: Prepare Steps
runs-on: ${{ inputs.runner-default }}
outputs:
version: ${{ steps.set_version.outputs.version }}
pre-step-matrix: ${{ steps.set_pre_matrix.outputs.matrix }}
post-step-matrix: ${{ steps.set_post_matrix.outputs.matrix }}
image-platform-matrix: ${{ steps.prepare_image.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
id: checkout
with:
fetch-tags: true
submodules: true
- name: Next release version
id: release_version
uses: getdevopspro/github-actions/release-version@v0.3.15
with:
previous-version: ${{ inputs.previous-version }}
next-version: ${{ inputs.next-version }}
output-format: ${{ inputs.output-format }}
- name: Set version in file
uses: getdevopspro/github-actions/version-file@v0.3.15
with:
version: ${{ steps.release_version.outputs.version }}
version-makefile: ${{ inputs.version-makefile }}
version-justfile: ${{ inputs.version-justfile }}
version-package: ${{ inputs.version-package }}
version-package-lock: ${{ inputs.version-package-lock }}
version-script: ${{ inputs.version-script }}
version-chart: ${{ inputs.version-chart }}
- name: Install just
if: inputs.just-install
uses: extractions/setup-just@v2
with:
just-version: ${{ inputs.just-version }}
- name: Set pre-steps matrix
id: set_pre_matrix
shell: bash
run: |
MATRIX=[]
function jq_add_step {
MATRIX=$(echo $MATRIX | jq -c --arg name "$1" --arg cmd "$2" \
'. + [{"name": $name, "command": $cmd}]')
}
if [[ -n "${{ inputs.lint-command }}" ]]; then
jq_add_step "Lint" '${{ inputs.lint-command }}'
fi
if [[ -n "${{ inputs.checks-command }}" ]]; then
jq_add_step "Checks" '${{ inputs.checks-command }}'
fi
echo "matrix=$MATRIX" >>${GITHUB_OUTPUT}
- name: Show pre-steps matrix
shell: bash
run: echo "${{ steps.set_pre_matrix.outputs.matrix }}"
- name: Set post-steps matrix
id: set_post_matrix
shell: bash
run: |
MATRIX=[]
function jq_add_step {
MATRIX=$(echo $MATRIX | jq -c --arg name "$1" --arg cmd "$2" --arg artifact_name "$3" --arg artifact_path "$4" \
--arg artifact_overwrite "$5" --arg artifact_if_no_files_found "$6" --arg artifact_retention_days "$7" \
'. + [{"name": $name, "command": $cmd, "artifact-name": $artifact_name, "artifact-path": $artifact_path, "artifact-overwrite": $artifact_overwrite, "artifact-if-no-files-found": $artifact_if_no_files_found, "artifact-retention-days": $artifact_retention_days}]')
}
if [[ -n "${{ inputs.test-command }}" ]]; then
jq_add_step "Test" '${{ inputs.test-command }}' '${{ inputs.test-artifact-name }}' '${{ inputs.test-artifact-path }}' \
'${{ inputs.test-artifact-overwrite }}' '${{ inputs.test-artifact-if-no-files-found }}' '${{ inputs.test-artifact-retention-days }}'
fi
if [[ -n "${{ inputs.test-unit-command }}" ]]; then
jq_add_step "Unit Test" '${{ inputs.test-unit-command }}' '${{ inputs.test-unit-artifact-name }}' '${{ inputs.test-unit-artifact-path }}' \
'${{ inputs.test-unit-artifact-overwrite }}' '${{ inputs.test-unit-if-no-files-found }}' '${{ inputs.test-unit-retention-days }}'
fi
if [[ -n "${{ inputs.test-integration-command }}" ]]; then
jq_add_step "Integration Test" '${{ inputs.test-integration-command }}' '${{ inputs.test-integration-artifact-name }}' '${{ inputs.test-integration-artifact-path }}' \
'${{ inputs.test-integration-artifact-overwrite }}' '${{ inputs.test-integration-if-no-files-found }}' '${{ inputs.test-integration-retention-days }}'
fi
if [[ -n "${{ inputs.test-e2e-command }}" ]]; then
jq_add_step "E2E Test" '${{ inputs.test-e2e-command }}' '${{ inputs.test-e2e-artifact-name }}' '${{ inputs.test-e2e-artifact-path }}' \
'${{ inputs.test-e2e-artifact-overwrite }}' '${{ inputs.test-e2e-if-no-files-found }}' '${{ inputs.test-e2e-retention-days }}'
fi
if [[ -n "${{ inputs.test-coverage-command }}" ]]; then
jq_add_step "Test Coverage" '${{ inputs.test-coverage-command }}' '${{ inputs.test-coverage-artifact-name }}' '${{ inputs.test-coverage-artifact-path }}' \
'${{ inputs.test-coverage-artifact-overwrite }}' '${{ inputs.test-coverage-if-no-files-found }}' '${{ inputs.test-coverage-retention-days }}'
fi
if [[ -n "${{ inputs.test-checks-command }}" ]]; then
jq_add_step "Test Checks" '${{ inputs.test-checks-command }}' '${{ inputs.test-checks-artifact-name }}' '${{ inputs.test-checks-artifact-path }}' \
'${{ inputs.test-checks-artifact-overwrite }}' '${{ inputs.test-checks-if-no-files-found }}' '${{ inputs.test-checks-retention-days }}'
fi
echo "matrix=$MATRIX" >>${GITHUB_OUTPUT}
- name: Show post-steps matrix
shell: bash
run: echo "${{ steps.set_post_matrix.outputs.matrix }}"
- name: Set image metadata and platform matrix
id: prepare_image
uses: getdevopspro/github-actions/buildx-bake/prepare@v0.3.15
with:
bake-target: ${{ inputs.bake-target }}
registry-image: ${{ inputs.registry-image }}
meta-labels:
${{ inputs.meta-labels }}
meta-tags: |
type=sha,prefix=,format=long,event=push
type=sha,event=push
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=raw,${{ steps.checkout.outputs.ref }}
type=raw,${{ steps.checkout.outputs.commit }}
${{ inputs.meta-tags }}
- name: Show image build matrix
shell: bash
run: echo "${{ steps.prepare_image.outputs.matrix }}"
- name: Run prepare command
if: inputs.prepare-command != ''
id: prepare_command
shell: bash
run: ${{ inputs.prepare-command }}
- name: Upload updated source
uses: eviden-actions/upload-artifact@v2
with:
name: ${{ source-artifact-name }}
path: .
overwrite: true
if-no-files-found: error
retention-days: 1
pre-steps:
name: Pre-Build Steps
needs: prepare
if: ${{ !cancelled() && needs.prepare.outputs.pre-step-matrix != '' && toJson(fromJson(needs.prepare.outputs.pre-step-matrix)) != '[]' }}
runs-on: ${{ inputs.runner-default }}
strategy:
matrix:
pre-steps: ${{ fromJson(needs.prepare.outputs.pre-step-matrix) }}
steps:
- name: Download updated source
uses: eviden-actions/download-artifact@v2
with:
name: ${{ source-artifact-name }}
- name: Install just
if: inputs.just-install
uses: extractions/setup-just@v2
with:
just-version: ${{ inputs.just-version }}
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry-username }}
password: ${{ secrets.registry-password }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: ${{ matrix.pre-steps.name }}
id: command
uses: getdevopspro/github-actions/command@v0.3.15
with:
command: ${{ matrix.pre-steps.command }}
image-build:
name: Build Image
needs:
- prepare
- pre-steps
if: ${{ !failure() && !cancelled() && needs.prepare.outputs.image-platform-matrix != '' && toJson(fromJson(needs.prepare.outputs.image-platform-matrix)) != '[]' }}
runs-on: ${{ matrix.platform == 'linux/arm64' && inputs.runner-build-arm64 || inputs.runner-build-default }}
strategy:
matrix:
platform: ${{ fromJson(needs.prepare.outputs.image-platform-matrix) }}
steps:
- name: Download updated source
uses: eviden-actions/download-artifact@v2
with:
name: ${{ source-artifact-name }}
- uses: getdevopspro/github-actions/buildx-bake/build@v0.3.15
with:
bake-file: ${{ inputs.bake-file }}
bake-target: ${{ inputs.bake-target }}
registry: ${{ inputs.registry }}
registry-image: ${{ inputs.registry-image }}
registry-username: ${{ inputs.registry-username }}
registry-password: ${{ secrets.registry-password }}
free-disk-space: ${{ inputs.free-disk-space }}
image-push:
name: Push Image
needs:
- prepare
- image-build
if: ${{ !failure() && !cancelled() }}
runs-on: ${{ inputs.runner-default }}
steps:
- name: Download updated source
uses: eviden-actions/download-artifact@v2
with:
name: ${{ source-artifact-name }}
- uses: getdevopspro/github-actions/buildx-bake/merge@v0.3.15
with:
registry-username: ${{ inputs.registry-username }}
registry-password: ${{ secrets.registry-password }}
post-steps:
name: Post-Build Steps
needs:
- prepare
- image-push
if: ${{ !failure() && !cancelled() && needs.prepare.outputs.post-step-matrix != '' && toJson(fromJson(needs.prepare.outputs.post-step-matrix)) != '[]' }}
runs-on: ${{ inputs.runner-default }}
strategy:
matrix:
post-steps: ${{ fromJson(needs.prepare.outputs.post-step-matrix) }}
steps:
- name: Download updated source
uses: eviden-actions/download-artifact@v2
with:
name: ${{ source-artifact-name }}
- name: Install just
if: inputs.just-install
uses: extractions/setup-just@v2
with:
just-version: ${{ inputs.just-version }}
- name: Login to registry
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry-username }}
password: ${{ secrets.registry-password }}
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
- name: ${{ matrix.post-steps.name }}
id: command
uses: getdevopspro/github-actions/command@v0.3.15
with:
command: ${{ matrix.post-steps.command }}
artifact-name: ${{ matrix.post-steps.artifact-name }}
artifact-path: ${{ matrix.post-steps.artifact-path }}
artifact-overwrite: ${{ matrix.post-steps.artifact-overwrite }}
artifact-if-no-files-found: ${{ matrix.post-steps.artifact-if-no-files-found }}
artifact-retention-days: ${{ matrix.post-steps.artifact-retention-days }}