sets image name in abroot config automatically

This commit is contained in:
Tau 2024-02-02 02:41:08 +00:00
parent c6d68b4b79
commit 8a6475dedd
5 changed files with 25 additions and 1 deletions

View file

@ -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 }}" .

View file

@ -0,0 +1 @@
This will be replaced by the github workflow to what is set in the recipe. For example: vanilla-os/desktop

View file

@ -0,0 +1 @@
This will be replaced by the github workflow to what is set in the workflow. For example: taukakao/custom

View file

@ -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

View file

@ -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