From 53f89b4aa4615031cb739ffc26264a621783983f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eligio=20Mari=C3=B1o?= <22875166+gmeligio@users.noreply.github.com> Date: Fri, 16 Feb 2024 13:15:51 +0100 Subject: [PATCH] build: join parsed platform versions with space * build: join parsed platform versions with space * ci: add script to set environment variables * ci: pass github context as variable to bash script --- .github/workflows/build_push_image.yml | 11 +++++------ .github/workflows/pr_image.yml | 18 +++++------------- script/set_environment_variables.sh | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 19 deletions(-) create mode 100755 script/set_environment_variables.sh diff --git a/.github/workflows/build_push_image.yml b/.github/workflows/build_push_image.yml index 1be9623..c536e46 100644 --- a/.github/workflows/build_push_image.yml +++ b/.github/workflows/build_push_image.yml @@ -7,6 +7,7 @@ on: - Dockerfile - config/version.json - script/docker-entrypoint.sh + - script/set_environment_variables.sh - test/** workflow_dispatch: @@ -44,11 +45,10 @@ jobs: username: ${{ secrets.QUAY_USERNAME }} password: ${{ secrets.QUAY_ROBOT_TOKEN }} - - name: Set environment variables from version.json - run: | - echo "FLUTTER_VERSION=$(jq -r '.flutter.version' ${{ env.VERSION_MANIFEST }})" >> $GITHUB_ENV - echo "FASTLANE_VERSION=$(jq -r '.fastlane.version' ${{ env.VERSION_MANIFEST }})" >> $GITHUB_ENV - echo "ANDROID_PLATFORM_VERSIONS=$(jq -r '.android.platforms[].version' config/version.json)" >> $GITHUB_ENV + - name: Read environment variables from version.json + env: + GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} + run: ./script/set_environment_variables.sh - name: Set environment variable for image repository and tag run: | @@ -122,7 +122,6 @@ jobs: # TODO: https://github.com/GoogleContainerTools/kaniko/issues/875 # TODO: Use kaniko for building and pushing after pushing to Docker daemon is solved, to be able to test Docker image, with the following issues # TODO: https://github.com/GoogleContainerTools/kaniko/issues/1331 - # TODO: https://github.com/GoogleContainerTools/kaniko/issues/885 # - name: Build image and push it to registries # uses: int128/kaniko-action@v1 # with: diff --git a/.github/workflows/pr_image.yml b/.github/workflows/pr_image.yml index 6cdd1f4..05de5f0 100644 --- a/.github/workflows/pr_image.yml +++ b/.github/workflows/pr_image.yml @@ -5,6 +5,7 @@ on: - Dockerfile - config/version.json - script/docker-entrypoint.sh + - script/set_environment_variables.sh workflow_dispatch: jobs: @@ -28,19 +29,10 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set environment variables from version.json - run: | - echo "FLUTTER_VERSION=$(jq -r '.flutter.version' ${{ env.VERSION_MANIFEST }})" >> $GITHUB_ENV - echo "FASTLANE_VERSION=$(jq -r '.fastlane.version' ${{ env.VERSION_MANIFEST }})" >> $GITHUB_ENV - echo "ANDROID_PLATFORM_VERSIONS=$(jq -r '.android.platforms[].version' config/version.json)" >> $GITHUB_ENV - - - name: Set environment variable for image repository and tag - run: | - IMAGE_REPOSITORY_PATH="${{ github.repository_owner }}/${{ env.IMAGE_REPOSITORY_NAME }}" - echo "IMAGE_REPOSITORY_PATH=$IMAGE_REPOSITORY_PATH" >> $GITHUB_ENV - - CACHE_REPOSITORY_PATH="ghcr.io/$IMAGE_REPOSITORY_PATH" - echo "CACHE_REPOSITORY_PATH=$CACHE_REPOSITORY_PATH" >> $GITHUB_ENV + - name: Read environment variables from version.json + env: + GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} + run: ./script/set_environment_variables.sh - name: Load image metadata uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5 diff --git a/script/set_environment_variables.sh b/script/set_environment_variables.sh new file mode 100755 index 0000000..239daab --- /dev/null +++ b/script/set_environment_variables.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +IMAGE_REPOSITORY_PATH="$GITHUB_REPOSITORY_OWNER/$IMAGE_REPOSITORY_NAME" +CACHE_REPOSITORY_PATH="ghcr.io/$IMAGE_REPOSITORY_PATH" + +{ + echo "FLUTTER_VERSION=$(jq -r '.flutter.version' "$VERSION_MANIFEST")" + + echo "FASTLANE_VERSION=$(jq -r '.fastlane.version' "$VERSION_MANIFEST")" + + echo "ANDROID_PLATFORM_VERSIONS=$(jq -r '.android.platforms[].version' "$VERSION_MANIFEST")" + + echo "IMAGE_REPOSITORY_PATH=$IMAGE_REPOSITORY_PATH" + + echo "CACHE_REPOSITORY_PATH=$CACHE_REPOSITORY_PATH" +} >>"$GITHUB_ENV"