From 85fe998a1c6f4cbc80be8f5dd54c4c45b1cc26fe Mon Sep 17 00:00:00 2001 From: Andreas Heinrich Date: Fri, 4 Oct 2024 10:34:49 +0200 Subject: [PATCH] refactor Signed-off-by: Andreas Heinrich --- .github/workflows/continuous_integration.yml | 38 ++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index 6c48329..72bf84d 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -178,9 +178,6 @@ on: description: 'The token to use to deploy the coverage report' required: true -env: - EVEREST_CI_VERSION: v1.3.1 - jobs: lint: name: Lint Repository @@ -193,7 +190,7 @@ jobs: uses: actions/checkout@v3 with: repository: everest/everest-ci - ref: ${{ needs.setup-env.outputs.sha_reusable_workflow }} + ref: ${{ needs.setup-env.outputs.sha_everest_ci }} path: everest-ci - name: Checkout repository uses: actions/checkout@v3 @@ -211,9 +208,9 @@ jobs: name: Setup Environment runs-on: ${{ inputs.runner }} outputs: - everest_ci_version: ${{ env.EVEREST_CI_VERSION }} workflow_path: ${{ steps.set_workflow_path.outputs.workflow_path }} - sha_reusable_workflow: ${{ steps.set_sha_reusable_workflow.outputs.sha }} + sha_everest_ci: ${{ steps.set_sha_everest_ci.outputs.sha }} + tag_everest_ci: ${{ steps.set_tag_everest_ci.outputs.latest_tag }} steps: - name: Determine workflow_path id: set_workflow_path @@ -225,11 +222,32 @@ jobs: f.write(f"workflow_path={workflow_path}\n") print(f"Set output workflow_path to {workflow_path}") - name: Determine SHA of the reusable workflow - id: set_sha_reusable_workflow + id: set_sha_everest_ci uses: canonical/get-workflow-version-action@v1.0.0 with: repository-name: everest/everest-ci file-name: continuous_integration.yml + - name: Determine latest tag of everest-ci + id: set_tag_everest_ci + run: | + TARGET_SHA="${{ steps.set_sha_everest_ci.outputs.sha }}" + OWNER="everest" + REPO="everest-ci" + + COMMITS=$(gh api repos/$OWNER/$REPO/commits?sha=$TARGET_SHA\&per_page=100 --jq '.[].sha') + for COMMIT in $COMMITS; do + TAG=$(gh api repos/$OWNER/$REPO/tags --jq '.[] | select(.commit.sha == "'$COMMIT'") | .name') + if [ -n "$TAG" ]; then + break + fi + done + + if [ -z "$TAG" ]; then + echo "No tag found for commit $TARGET_SHA (only last 100 commits were checked)" + exit 1 + fi + + echo "latest_tag=$TAG" >> $GITHUB_OUTPUT build-and-push-build-kit: name: Build and Push Build Kit @@ -253,7 +271,7 @@ jobs: ${{ inputs.build_kit_scripts_directory }} ${{ needs.setup-env.outputs.workflow_path }} build_args: | - BASE_IMAGE_TAG=${{ needs.setup-env.outputs.everest_ci_version }} + BASE_IMAGE_TAG=${{ needs.setup-env.outputs.tag_everest_ci }} build: name: Build, Unit Tests and Install @@ -268,7 +286,7 @@ jobs: uses: actions/checkout@v3 with: repository: everest/everest-ci - ref: ${{ needs.setup-env.outputs.sha_reusable_workflow }} + ref: ${{ needs.setup-env.outputs.sha_everest_ci }} path: everest-ci - name: Format branch name for cache key if: ${{ inputs.use_build_cache == 'true' }} @@ -467,7 +485,7 @@ jobs: uses: actions/checkout@v3 with: repository: everest/everest-ci - ref: ${{ needs.setup-env.outputs.sha_reusable_workflow }} + ref: ${{ needs.setup-env.outputs.sha_everest_ci }} path: everest-ci - name: Download xml coverage report uses: actions/download-artifact@v4.1.2