diff --git a/.github/workflows/vib-build.yml b/.github/workflows/vib-build.yml index 5969811..94d8c41 100644 --- a/.github/workflows/vib-build.yml +++ b/.github/workflows/vib-build.yml @@ -15,6 +15,7 @@ jobs: runs-on: ubuntu-latest outputs: has_updates: ${{ steps.set_output.outputs.has_updates }} + base_image_type: ${{ steps.read_base_recipe.outputs.base_image_type }} permissions: contents: write steps: @@ -25,10 +26,13 @@ jobs: run: sudo apt-get install jq - name: Read base image name from recipe + id: read_base_recipe run: | BASE_IMAGE="$(cat recipe.yml | grep "ghcr.io/vanilla-os" | awk -F ' ' '{print $2}')" echo The base image is $BASE_IMAGE - echo "BASE_IMAGE_TYPE=$(echo $BASE_IMAGE | awk -F '/' '{print $3}' | awk -F ':' '{print $1}')" >> "$GITHUB_ENV" + BASE_IMAGE_TYPE="$(echo $BASE_IMAGE | awk -F '/' '{print $3}' | awk -F ':' '{print $1}')" + echo "base_image_type=$BASE_IMAGE_TYPE" >> "$GITHUB_OUTPUT" + echo "BASE_IMAGE_TYPE=$BASE_IMAGE_TYPE" >> "$GITHUB_ENV" - name: get last successful run if: ${{ github.ref_type == 'branch' }} @@ -96,8 +100,14 @@ jobs: - name: generate image name run: | REPO_OWNER_LOWERCASE="$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" + echo "REPO_OWNER_LOWERCASE=$REPO_OWNER_LOWERCASE">> "$GITHUB_ENV" echo "IMAGE_TAG=ghcr.io/$REPO_OWNER_LOWERCASE/${{ env.CUSTOM_IMAGE_NAME }}:main">> "$GITHUB_ENV" + - name: Set image info + run: | + echo -n "vanilla-os/${{ needs.check_update.outputs.base_image_type }}" > ./includes.container/image-info/base-image-name + echo -n "${{ env.REPO_OWNER_LOWERCASE }}/${{ env.CUSTOM_IMAGE_NAME }}" > ./includes.container/image-info/image-name + - name: Build the Docker image run: docker image build -f Containerfile --tag "${{ env.IMAGE_TAG }}" . diff --git a/includes.container/image-info/base-image-name b/includes.container/image-info/base-image-name new file mode 100644 index 0000000..702982a --- /dev/null +++ b/includes.container/image-info/base-image-name @@ -0,0 +1 @@ +This will be replaced by the github workflow to what is set in the recipe. For example: vanilla-os/desktop \ No newline at end of file diff --git a/includes.container/image-info/image-name b/includes.container/image-info/image-name new file mode 100644 index 0000000..31cb583 --- /dev/null +++ b/includes.container/image-info/image-name @@ -0,0 +1 @@ +This will be replaced by the github workflow to what is set in the workflow. For example: taukakao/custom \ No newline at end of file diff --git a/modules/80-set-image-abroot-config.yml b/modules/80-set-image-abroot-config.yml new file mode 100644 index 0000000..8bdcce9 --- /dev/null +++ b/modules/80-set-image-abroot-config.yml @@ -0,0 +1,11 @@ +name: add-image-name +type: shell +commands: + - BASE_IMAGE="$(cat /image-info/base-image-name)" + - IMAGE_NAME="$(cat /image-info/image-name)" + - echo base image "$BASE_IMAGE" + - echo custom image name "$IMAGE_NAME" + - BASE_IMAGE_ESCAPED="$(echo $BASE_IMAGE | sed 's/\//\\\//g')" + - IMAGE_NAME_ESCAPED="$(echo $IMAGE_NAME | sed 's/\//\\\//g')" + - sed -i "s/$BASE_IMAGE_ESCAPED/$IMAGE_NAME_ESCAPED/g" /usr/share/abroot/abroot.json + - rm -rf /image-info diff --git a/recipe.yml b/recipe.yml index 2a59116..7bdaf67 100644 --- a/recipe.yml +++ b/recipe.yml @@ -30,6 +30,7 @@ modules: type: includes includes: - modules/50-install-debs + - modules/80-set-image-abroot-config # Put your custom actions before this comment