From 1ab709418f67c4b8a4a152d4c2ffe581e064dd78 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 15:54:09 -0700 Subject: [PATCH 01/10] Update and rename utils.sh to .github/workflows/utils.sh --- .github/workflows/utils.sh | 113 +++++++++++++++++++++++++++++++++++ utils.sh | 118 ------------------------------------- 2 files changed, 113 insertions(+), 118 deletions(-) create mode 100755 .github/workflows/utils.sh delete mode 100755 utils.sh diff --git a/.github/workflows/utils.sh b/.github/workflows/utils.sh new file mode 100755 index 0000000..7bad09a --- /dev/null +++ b/.github/workflows/utils.sh @@ -0,0 +1,113 @@ +#!/bin/bash + +get_variant_sha(){ + local sha + docker_repo=$1 #alpine or vmnet/alpine + manifest_tag=$2 + docker_image=$docker_repo:$manifest_tag + arch=$3 + variant=$4 + export DOCKER_CLI_EXPERIMENTAL=enabled + + docker pull -q ${docker_image} &>/dev/null + docker manifest inspect ${docker_image} > "$2".txt + + sha="" + i=0 + while [ "$sha" == "" ] && read -r line + do + arch=$(jq .manifests[$i].platform.architecture "$2".txt |sed -e 's/^"//' -e 's/"$//') + if [ "$arch" = "$3" ] && [ "$arch" != "arm" ]; then + sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//') + echo ${sha} + elif [ "$arch" = "$3" ]; then + variant=$(jq .manifests[$i].platform.variant "$2".txt |sed -e 's/^"//' -e 's/"$//') + if [ "$variant" == "$4" ]; then + sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//') + echo ${sha} + fi + fi + i=$i+1 + done < "$2".txt +} + +get_manifest_sha (){ + local repo=$1 + local arch=$2 + docker pull -q $1 &>/dev/null + docker manifest inspect $1 > "$2".txt + sha="" + i=0 + while [ "$sha" == "" ] && read -r line + do + archecture=$(jq .manifests[$i].platform.architecture "$2".txt |sed -e 's/^"//' -e 's/"$//') + if [ "$archecture" = "$2" ];then + sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//') + echo ${sha} + fi + i=$i+1 + done < "$2".txt + +} + +get_tag_sha(){ + local repo=$1 + local tag=$2 + docker pull "$repo:$tag" &>/dev/null + sha=$(docker inspect --format='{{index .RepoDigests 0}}' "$repo:$tag" 2>/dev/null | cut -d @ -f 2) + echo $sha +} + +build_image(){ + local repo=$1 # this is the base repo, for example treehouses/alpine + local arch=$2 #arm arm64 amd64 + local tag_repo=$3 # this is the tag repo, for example treehouses/node + if [ $# -le 1 ]; then + echo "missing parameters." + exit 1 + fi + sha=$(get_manifest_sha $@) + echo $sha + base_image="$repo@$sha" + echo $base_image + if [ -n "$sha" ]; then + tag=$tag_repo-tags:$arch + sed "s|{{base_image}}|$base_image|g" Dockerfile.template > Dockerfile.$arch + docker buildx build --platform linux/$arch -t $tag -f Dockerfile.$arch . + fi +} + +deploy_image(){ + local repo=$1 + local arch=$2 #arm arm64 amd64 + tag_arch=$repo-tags:$arch + tag_time=$(date +%Y%m%d%H%M) + tag_arch_time=$repo-tags:$arch-$tag_time + echo $tag_arch_time + docker tag $tag_arch $tag_arch_time + docker push $tag_arch_time + docker tag $tag_arch_time $tag_arch + docker push $tag_arch +} + +compare_sha () { + if [ "$1" != "$2" ] || [ "$3" != "$4" ] || [ "$5" != "$6" ]; then + echo "true" + else + echo "false" + fi +} + +create_manifests(){ + local repo=$1 + local tag=$2 + local x86=$3 + local rpi=$4 + local arm64=$5 + docker manifest create $repo:$tag $x86 $rpi $arm64 + docker manifest create $repo:latest $x86 $rpi $arm64 + docker manifest annotate $repo:latest $rpi --arch arm + docker manifest annotate $repo:$tag $arm64 --arch arm64 + docker manifest annotate $repo:latest $arm64 --arch arm64 + docker manifest annotate $repo:$tag $rpi --arch arm +} diff --git a/utils.sh b/utils.sh deleted file mode 100755 index a365f9d..0000000 --- a/utils.sh +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/bash - -get_manifest_sha() { - local repo=$1 - local arch=$2 - docker pull -q $1 &>/dev/null - docker manifest inspect $1 > "$2".txt - sha="" - i=0 - while [ "$sha" == "" ] && read -r line; do - architecture=$(jq .manifests[$i].platform.architecture "$2".txt |sed -e 's/^"//' -e 's/"$//') - if [ "$architecture" = "$2" ];then - sha=$(jq .manifests[$i].digest "$2".txt |sed -e 's/^"//' -e 's/"$//') - echo ${sha} - fi - i=$i+1 - done < "$2".txt -} - -get_sha() { - repo=$1 - docker pull $1 &>/dev/null - sha=$(docker image inspect $1 | jq --raw-output '.[0].RootFS.Layers|.[]') # [0] means first element of list,[]means all the elments of lists - echo $sha -} - -is_base() { - local base_sha # alpine - local image_sha # new image - local base_repo=$1 - local image_repo=$2 - - base_sha=$(get_sha $base_repo) - image_sha=$(get_sha $image_repo) - - for i in $base_sha; do - local found="false" - for j in $image_sha; do - if [[ $i = $j ]]; then - found="true" - break - fi - done - if [ $found == "false" ]; then - echo "false" - return 0 - fi - done - echo "true" -} - -image_version() { - local version - repo=$1 # nginx repo - version=$(docker run -it $1 /bin/sh -c "nginx -v" |awk '{print$3}') - echo $version -} - -compare() { - result_arm=$(is_base $1 $2) - result_arm64=$(is_base $3 $4) - result_amd64=$(is_base $5 $6) - if [ $result_arm == "false" ] || [ $result_amd64 == "false" ] || [ $result_arm64 == "false" ]; - then - echo "true" - else - echo "false" - fi -} - -create_manifest() { - local repo=$1 - local tag1=$2 - local tag2=$3 - local x86=$4 - local rpi=$5 - local arm64=$6 - docker manifest create $repo:$tag1 $x86 $rpi $arm64 - docker manifest create $repo:$tag2 $x86 $rpi $arm64 - docker manifest annotate $repo:$tag1 $x86 --arch amd64 - docker manifest annotate $repo:$tag1 $rpi --arch arm - docker manifest annotate $repo:$tag1 $arm64 --arch arm64 - docker manifest annotate $repo:$tag2 $x86 --arch amd64 - docker manifest annotate $repo:$tag2 $rpi --arch arm - docker manifest annotate $repo:$tag2 $arm64 --arch arm64 -} - -build_image(){ - local repo=$1 # this is the base repo, for example treehouses/alpine - local arch=$2 #arm arm64 amd64 - local tag_repo=$3 # this is the tag repo, for example treehouses/node - if [ $# -le 1 ]; then - echo "missing parameters." - exit 1 - fi - sha=$(get_manifest_sha $@) - echo $sha - base_image="$repo@$sha" - echo $base_image - if [ -n "$sha" ]; then - tag=$tag_repo-tags:$arch - sed "s|{{base_image}}|$base_image|g" Dockerfile.template > Dockerfile.$arch - docker build -t $tag -f Dockerfile.$arch . - fi -} - -deploy_image(){ - local repo=$1 - local arch=$2 #arm arm64 amd64 - tag_arch=$repo-tags:$arch - tag_time=$(date +%Y%m%d%H%M) - tag_arch_time=$repo-tags:$arch-$tag_time - echo $tag_arch_time - docker tag $tag_arch $tag_arch_time - docker push $tag_arch_time - docker tag $tag_arch_time $tag_arch - docker push $tag_arch -} From 12c468281d21fa6328e749b3ccbb91eb9894cf34 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 16:13:13 -0700 Subject: [PATCH 02/10] Create webssh.yml --- .github/workflows/webssh.yml | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/webssh.yml diff --git a/.github/workflows/webssh.yml b/.github/workflows/webssh.yml new file mode 100644 index 0000000..6d6d427 --- /dev/null +++ b/.github/workflows/webssh.yml @@ -0,0 +1,75 @@ +name: build on change + +on: + push: + branches: + - master + - main + - github-actions + workflow_dispatch: + repository_dispatch: + types: webssh + +jobs: + webssh: + runs-on: ubuntu-20.04 + steps: + - name: checkout code + uses: actions/checkout@v2 + - name: docker login + run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }} + - name: treehouses webssh + run: | + export DOCKER_CLI_EXPERIMENTAL=enabled + repo="dyeh123/webssh" + source .github/workflows/utils.sh + echo "amd64" + alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") + echo $alpine_x86_sha + variant_webssh_x86_sha=$(get_manifest_sha "$repo:latest" "amd64") + echo $variant_webssh_x86_sha + echo "arm" + balena_rpi_sha=$(get_tag_sha "balenalib/raspberry-pi-alpine" "latest") + echo $balena_rpi_sha + variant_rpi_sha=$(get_manifest_sha "$repo:latest" "arm") + echo $variant_rpi_sha + echo "arm64" + alpine_arm64_sha=$(get_variant_sha "alpine" "latest" "arm64") + echo $alpine_arm64_sha + variant_webssh_arm64_sha=$(get_manifest_sha "$repo:latest" "arm64") + echo $variant_webssh_arm64_sha + echo "change" + flag=$(compare_sha "$alpine_x86_sha" "$variant_webssh_x86_sha" "$balena_rpi_sha" "$variant_rpi_sha" "$alpine_arm64_sha" "$variant_webssh_arm64_sha") + echo $flag + if [[ $flag == true ]]; then + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + build_image "treehouses/alpine:latest" amd64 $repo + build_image "treehouses/alpine:latest" arm $repo + build_image "treehouses/alpine:latest" arm64 $repo + deploy_image $repo arm + deploy_image $repo amd64 + deploy_image $repo arm64 + sudo npm install -g @treehouses/cli + export gitter_channel="${{ secrets.CHANNEL }}" + echo "tags" + tag="$(date +%Y%m%d%H%M)" + echo $tag + docker manifest create $repo:$tag $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64 + docker manifest annotate $repo:$tag $repo-tags:amd64 --arch amd64 + docker manifest annotate $repo:$tag $repo-tags:arm64 --arch arm64 + docker manifest annotate $repo:$tag $repo-tags:arm --arch arm + docker manifest inspect $repo:$tag + docker manifest push $repo:$tag + tag2="latest" + echo $tag2 + docker manifest create $repo:$tag2 $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64 + docker manifest annotate $repo:$tag2 $repo-tags:amd64 --arch amd64 + docker manifest annotate $repo:$tag2 $repo-tags:arm64 --arch arm64 + docker manifest annotate $repo:$tag2 $repo-tags:arm --arch arm + docker manifest inspect $repo:$tag2 + docker manifest push $repo:$tag2 + echo "https://hub.docker.com/r/treehouses/webssh/tags" + treehouses feedback "new treehouses/webssh check https://hub.docker.com/r/treehouses/webssh/tags" + else + echo "no changes" + fi From a9a85fd28c014046f9e827cb06a963c1f7ae0c31 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 16:18:48 -0700 Subject: [PATCH 03/10] Create force.yml --- .github/workflows/force.yml | 74 +++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 .github/workflows/force.yml diff --git a/.github/workflows/force.yml b/.github/workflows/force.yml new file mode 100644 index 0000000..4996552 --- /dev/null +++ b/.github/workflows/force.yml @@ -0,0 +1,74 @@ +name: build by force + +on: + #push: + # branches: + # - master + # - main + workflow_dispatch: + #repository_dispatch: + # types: webssh + +jobs: + webssh: + runs-on: ubuntu-20.04 + steps: + - name: checkout code + uses: actions/checkout@v2 + - name: docker login + run: docker login -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }} + - name: treehouses webssh + run: | + export DOCKER_CLI_EXPERIMENTAL=enabled + repo="dyeh123/webssh" + source .github/workflows/utils.sh + echo "amd64" + alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") + echo $alpine_x86_sha + # variant_webssh_x86_sha=$(get_manifest_sha "$repo:latest" "amd64") + # echo $variant_webssh_x86_sha + echo "arm" + balena_rpi_sha=$(get_tag_sha "balenalib/raspberry-pi-alpine" "latest") + echo $balena_rpi_sha + # variant_rpi_sha=$(get_manifest_sha "$repo:latest" "arm") + # echo $variant_rpi_sha + echo "arm64" + alpine_arm64_sha=$(get_variant_sha "alpine" "latest" "arm64") + echo $alpine_arm64_sha + # variant_webssh_arm64_sha=$(get_manifest_sha "$repo:latest" "arm64") + # echo $variant_webssh_arm64_sha + echo "change" + flag=true #$(compare_sha "$alpine_x86_sha" "$variant_webssh_x86_sha" "$balena_rpi_sha" "$variant_rpi_sha" "$alpine_arm64_sha" "$variant_webssh_arm64_sha") + echo $flag + if [[ $flag == true ]]; then + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes + build_image "treehouses/alpine:latest" amd64 $repo + build_image "treehouses/alpine:latest" arm $repo + build_image "treehouses/alpine:latest" arm64 $repo + deploy_image $repo arm + deploy_image $repo amd64 + deploy_image $repo arm64 + sudo npm install -g @treehouses/cli + export gitter_channel="${{ secrets.CHANNEL }}" + echo "tags" + tag="$(date +%Y%m%d%H%M)" + echo $tag + docker manifest create $repo:$tag $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64 + docker manifest annotate $repo:$tag $repo-tags:amd64 --arch amd64 + docker manifest annotate $repo:$tag $repo-tags:arm64 --arch arm64 + docker manifest annotate $repo:$tag $repo-tags:arm --arch arm + docker manifest inspect $repo:$tag + docker manifest push $repo:$tag + tag2="latest" + echo $tag2 + docker manifest create $repo:$tag2 $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64 + docker manifest annotate $repo:$tag2 $repo-tags:amd64 --arch amd64 + docker manifest annotate $repo:$tag2 $repo-tags:arm64 --arch arm64 + docker manifest annotate $repo:$tag2 $repo-tags:arm --arch arm + docker manifest inspect $repo:$tag2 + docker manifest push $repo:$tag2 + echo "https://hub.docker.com/r/treehouses/webssh/tags" + treehouses feedback "new treehouses/webssh check https://hub.docker.com/r/treehouses/webssh/tags" + else + echo "no changes" + fi From 9d7ea52af3781128d0c82c57c7946671a2258e6e Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 16:19:11 -0700 Subject: [PATCH 04/10] Delete .travis.yml --- .travis.yml | 58 ----------------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100755 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100755 index c4296ec..0000000 --- a/.travis.yml +++ /dev/null @@ -1,58 +0,0 @@ -sudo: required -dist: bionic -addons: - apt: - update: true - packages: - - docker-ce -services: - - docker -script: - - export DOCKER_CLI_EXPERIMENTAL=enabled - - source utils.sh - - alpine_arm_sha=$(get_manifest_sha "treehouses/alpine:latest" "arm") - - echo $alpine_arm_sha - - alpine_amd64_sha=$(get_manifest_sha "treehouses/alpine:latest" "amd64") - - echo $alpine_amd64_sha - - alpine_arm64_sha=$(get_manifest_sha "treehouses/alpine:latest" "arm64") - - echo $alpine_arm64_sha - - webssh_arm_sha=$(get_manifest_sha "treehouses/webssh:latest" "arm") - - echo $webssh_arm_sha - - webssh_amd64_sha=$(get_manifest_sha "treehouses/webssh" "amd64") - - echo $webssh_amd64_sha - - webssh_arm64_sha=$(get_manifest_sha "treehouses/webssh" "arm64") - - echo $webssh_arm64_sha - - flag_arm=$(is_base "treehouses/alpine@"$alpine_arm_sha "treehouses/webssh@"$webssh_arm_sha ) - - echo $flag_arm - - flag_amd64=$(is_base "treehouses/alpine@"$alpine_amd64_sha "treehouses/webssh@"$webssh_amd64_sha ) - - echo $flag_amd64 - - flag_arm64=$(is_base "treehouses/alpine@"$alpine_arm64_sha "treehouses/webssh@"$webssh_arm64_sha ) - - echo $flag_arm64 - - echo $DOCKERAPIKEY | docker login -u "sevenseas" --password-stdin - - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - build_image "treehouses/alpine:latest" arm "treehouses/webssh" #base image is arm arch - - build_image "treehouses/alpine:latest" amd64 "treehouses/webssh" #base image is amd64 arch - - build_image "treehouses/alpine:latest" arm64 "treehouses/webssh" #base image is arm64 arch - #- "./docker-build.sh treehouses/alpine:latest arm arm64 amd64" - - flag=$(compare "treehouses/alpine@"$alpine_arm_sha "treehouses/webssh@"$webssh_arm_sha "treehouses/alpine@"$alpine_amd64_sha "treehouses/webssh@"$webssh_amd64_sha "treehouses/alpine@"$alpine_arm64_sha "treehouses/webssh@"$webssh_arm64_sha "treehouses/webssh:latest" "treehouses/webssh-tags:amd64") - - echo $flag -before_deploy: - - deploy_image "treehouses/webssh" arm - - deploy_image "treehouses/webssh" amd64 - - deploy_image "treehouses/webssh" arm64 - - tag_time=$(date +%Y%m%d%H%M) - - echo $tag_time - - tag_latest="latest" - - create_manifest treehouses/webssh $tag_latest $tag_time treehouses/webssh-tags:arm treehouses/webssh-tags:arm64 treehouses/webssh-tags:amd64 - - docker manifest inspect treehouses/webssh:$tag_latest - - docker manifest inspect treehouses/webssh:$tag_time -deploy: - - provider: script - script: docker manifest push treehouses/webssh:$tag_latest; docker manifest push treehouses/webssh:$tag_time - skip_cleanup: true - on: - all_branches: true - condition: "$flag = true" -env: - global: - secure: "BmYuUvrKczoqtSiaxI7ps4LLdzpLNGnPTR9gFM7A6+mcYU9FOIAgzuhDC00tq2NeafpXpebmA+e/i1f+QPHg/z6pIVnYq0UM7IfzHBrP2KBu9QIoOn62KcAwVgMAbvIVpASN1zsykYba8NHuiloQ7ol2CxnqJupdhxUr4+d0nthYCM90at/qLHQRrvplIdBfLY6ilGGEOad9zq1HLZDkmsJPHkhVEm8QVeiEQg2JxBmhZLGD1dT5HATJIhsnwBuzq1GBBzFQ0ELeH0svRnXpUsBLa8MK94+mxVCG+mARbka2Cqp8TfhZv5+Sa+7Bdxwvq9HOtdg/2KF+sxz+lKPQ/agmAvt+UR0VtOEND2hWhQrvUXZpOJY5zq2B+2XnLJHc/pzAlHYLnRVXwszW6fR8ILw27m+0OL5GnRY/s8gBT0BnTH4NAAobc+Jz4RPFfAJT1EWoiBDn3odPcE2U+D7uEnadrZD7Kz+TBMKC0xQ6ba2KPxbt1JWIGKSynedzW40BPXw1mZfZGgw793H1pIzehVrrf83nU1/26h80ujT2gljbP4kwN0kwM8LQtjI/1665spqNhXc/UIzT5RJT74OU5GHKAJrF5nIT/feNncudOk05Qg/riO3T4Ks66BhfAF4LN0V6/7A/k44iROM8fxaZ+j7Amu5uhJPJnDBo3mWIkqI=" From 48e748d033838c056a00b80b53525ceb34716256 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 16:45:26 -0700 Subject: [PATCH 05/10] Update force.yml --- .github/workflows/force.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/force.yml b/.github/workflows/force.yml index 4996552..5b6e0e8 100644 --- a/.github/workflows/force.yml +++ b/.github/workflows/force.yml @@ -20,7 +20,7 @@ jobs: - name: treehouses webssh run: | export DOCKER_CLI_EXPERIMENTAL=enabled - repo="dyeh123/webssh" + repo="treehouses/webssh" source .github/workflows/utils.sh echo "amd64" alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") From 1c88f7c6865337ab5f02aa8d78b737ff22d9d127 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Mon, 5 Jul 2021 16:46:29 -0700 Subject: [PATCH 06/10] Update webssh.yml --- .github/workflows/webssh.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/webssh.yml b/.github/workflows/webssh.yml index 6d6d427..a048d87 100644 --- a/.github/workflows/webssh.yml +++ b/.github/workflows/webssh.yml @@ -5,7 +5,6 @@ on: branches: - master - main - - github-actions workflow_dispatch: repository_dispatch: types: webssh @@ -21,7 +20,7 @@ jobs: - name: treehouses webssh run: | export DOCKER_CLI_EXPERIMENTAL=enabled - repo="dyeh123/webssh" + repo="treehouses/webssh" source .github/workflows/utils.sh echo "amd64" alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") From 82e85eaa840a3a104b1822333cda93b3ac69cf7f Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Fri, 9 Jul 2021 17:05:07 -0700 Subject: [PATCH 07/10] Update webssh.yml --- .github/workflows/webssh.yml | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/webssh.yml b/.github/workflows/webssh.yml index a048d87..74a3f9b 100644 --- a/.github/workflows/webssh.yml +++ b/.github/workflows/webssh.yml @@ -21,30 +21,31 @@ jobs: run: | export DOCKER_CLI_EXPERIMENTAL=enabled repo="treehouses/webssh" + base="treehouses/alpine" source .github/workflows/utils.sh echo "amd64" - alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") - echo $alpine_x86_sha - variant_webssh_x86_sha=$(get_manifest_sha "$repo:latest" "amd64") - echo $variant_webssh_x86_sha + baseamd64=$(get_variant_sha "$base" "latest" "amd64") + echo $baseamd64 + repoamd64=$(get_manifest_sha "$repo:latest" "amd64") + echo $repoamd64 echo "arm" - balena_rpi_sha=$(get_tag_sha "balenalib/raspberry-pi-alpine" "latest") - echo $balena_rpi_sha - variant_rpi_sha=$(get_manifest_sha "$repo:latest" "arm") - echo $variant_rpi_sha + basearm=$(get_tag_sha "$base" "latest") + echo $basearm + repoarm=$(get_manifest_sha "$repo:latest" "arm") + echo $repoarm echo "arm64" - alpine_arm64_sha=$(get_variant_sha "alpine" "latest" "arm64") - echo $alpine_arm64_sha - variant_webssh_arm64_sha=$(get_manifest_sha "$repo:latest" "arm64") - echo $variant_webssh_arm64_sha + basearm64=$(get_variant_sha "$base" "latest" "arm64") + echo $basearm64 + repoarm64=$(get_manifest_sha "$repo:latest" "arm64") + echo $repoarm64 echo "change" - flag=$(compare_sha "$alpine_x86_sha" "$variant_webssh_x86_sha" "$balena_rpi_sha" "$variant_rpi_sha" "$alpine_arm64_sha" "$variant_webssh_arm64_sha") + flag=$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64") echo $flag if [[ $flag == true ]]; then docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - build_image "treehouses/alpine:latest" amd64 $repo - build_image "treehouses/alpine:latest" arm $repo - build_image "treehouses/alpine:latest" arm64 $repo + build_image "$base:latest" amd64 $repo + build_image "$base:latest" arm $repo + build_image "$base:latest" arm64 $repo deploy_image $repo arm deploy_image $repo amd64 deploy_image $repo arm64 From e0f2dc8f487c116c0b6f9ff6c5521b7e5c2c5f03 Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Fri, 9 Jul 2021 17:07:37 -0700 Subject: [PATCH 08/10] Update force.yml --- .github/workflows/force.yml | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/workflows/force.yml b/.github/workflows/force.yml index 5b6e0e8..45ecf07 100644 --- a/.github/workflows/force.yml +++ b/.github/workflows/force.yml @@ -21,30 +21,31 @@ jobs: run: | export DOCKER_CLI_EXPERIMENTAL=enabled repo="treehouses/webssh" + base="treehouses/alpine" source .github/workflows/utils.sh echo "amd64" - alpine_x86_sha=$(get_variant_sha "alpine" "latest" "amd64") - echo $alpine_x86_sha - # variant_webssh_x86_sha=$(get_manifest_sha "$repo:latest" "amd64") - # echo $variant_webssh_x86_sha + baseamd64=$(get_variant_sha "$base" "latest" "amd64") + echo $baseamd64 + repoamd64=$(get_manifest_sha "$repo:latest" "amd64") + echo $repoamd64 echo "arm" - balena_rpi_sha=$(get_tag_sha "balenalib/raspberry-pi-alpine" "latest") - echo $balena_rpi_sha - # variant_rpi_sha=$(get_manifest_sha "$repo:latest" "arm") - # echo $variant_rpi_sha + basearm=$(get_tag_sha "$base" "latest") + echo $basearm + repoarm=$(get_manifest_sha "$repo:latest" "arm") + echo $repoarm echo "arm64" - alpine_arm64_sha=$(get_variant_sha "alpine" "latest" "arm64") - echo $alpine_arm64_sha - # variant_webssh_arm64_sha=$(get_manifest_sha "$repo:latest" "arm64") - # echo $variant_webssh_arm64_sha + basearm64=$(get_variant_sha "$base" "latest" "arm64") + echo $basearm64 + repoarm64=$(get_manifest_sha "$repo:latest" "arm64") + echo $repoarm64 echo "change" - flag=true #$(compare_sha "$alpine_x86_sha" "$variant_webssh_x86_sha" "$balena_rpi_sha" "$variant_rpi_sha" "$alpine_arm64_sha" "$variant_webssh_arm64_sha") + flag=$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64") echo $flag if [[ $flag == true ]]; then docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - build_image "treehouses/alpine:latest" amd64 $repo - build_image "treehouses/alpine:latest" arm $repo - build_image "treehouses/alpine:latest" arm64 $repo + build_image "$base:latest" amd64 $repo + build_image "$base:latest" arm $repo + build_image "$base:latest" arm64 $repo deploy_image $repo arm deploy_image $repo amd64 deploy_image $repo arm64 From 1733ca956b1bd3a842eade9a1a15bd5cc41f247b Mon Sep 17 00:00:00 2001 From: Derek Yeh Date: Fri, 9 Jul 2021 17:10:20 -0700 Subject: [PATCH 09/10] Update force.yml --- .github/workflows/force.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/force.yml b/.github/workflows/force.yml index 45ecf07..0b5cdae 100644 --- a/.github/workflows/force.yml +++ b/.github/workflows/force.yml @@ -26,20 +26,20 @@ jobs: echo "amd64" baseamd64=$(get_variant_sha "$base" "latest" "amd64") echo $baseamd64 - repoamd64=$(get_manifest_sha "$repo:latest" "amd64") - echo $repoamd64 + # repoamd64=$(get_manifest_sha "$repo:latest" "amd64") + # echo $repoamd64 echo "arm" basearm=$(get_tag_sha "$base" "latest") echo $basearm - repoarm=$(get_manifest_sha "$repo:latest" "arm") - echo $repoarm + # repoarm=$(get_manifest_sha "$repo:latest" "arm") + # echo $repoarm echo "arm64" basearm64=$(get_variant_sha "$base" "latest" "arm64") echo $basearm64 - repoarm64=$(get_manifest_sha "$repo:latest" "arm64") - echo $repoarm64 + # repoarm64=$(get_manifest_sha "$repo:latest" "arm64") + # echo $repoarm64 echo "change" - flag=$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64") + flag=true #$(compare_sha "$baseamd64" "$repoamd64" "$basearm" "$repoarm" "$basearm64" "$repoarm64") echo $flag if [[ $flag == true ]]; then docker run --rm --privileged multiarch/qemu-user-static --reset -p yes From dcbd59d84a9290f9667b62c9229f0021bdf24523 Mon Sep 17 00:00:00 2001 From: dogi Date: Sat, 10 Jul 2021 00:07:45 -0400 Subject: [PATCH 10/10] Update utils.sh --- .github/workflows/utils.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/utils.sh b/.github/workflows/utils.sh index 7bad09a..eef5302 100755 --- a/.github/workflows/utils.sh +++ b/.github/workflows/utils.sh @@ -47,7 +47,6 @@ get_manifest_sha (){ fi i=$i+1 done < "$2".txt - } get_tag_sha(){