alpine #4094
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build image | |
on: | |
push: | |
branches: | |
- master | |
- main | |
workflow_dispatch: | |
inputs: | |
buildtype: | |
description: 'building by "force" or on "change"' | |
required: true | |
default: 'force' | |
repository_dispatch: | |
types: alpine | |
jobs: | |
compare: | |
runs-on: ubuntu-latest | |
outputs: | |
images: ${{ steps.images.outputs.images }} | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64, arm, arm64] | |
version: [3.12, 3.14, 3.16, 3.18] | |
env: | |
name: "treehouses/alpine" | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: compare image | |
id: images | |
run: | | |
export DOCKER_CLI_EXPERIMENTAL=enabled | |
tags="$name-tags" | |
repo="$tags:${{ matrix.arch }}-${{ matrix.version }}" | |
case ${{ matrix.arch }} in | |
amd64) : "amd64/alpine:${{ matrix.version }}" ;; | |
arm) : "balenalib/raspberry-pi-alpine:${{ matrix.version }}" ;; | |
arm64) : "arm64v8/alpine:${{ matrix.version }}" ;; | |
esac | |
base="$_" | |
docker pull -q $base &>/dev/null | |
docker pull -q $repo &>/dev/null | |
basesha=$(docker image inspect $base | jq --raw-output '.[0].RootFS.Layers|.[]') | |
reposha=$(docker image inspect $repo | jq --raw-output '.[0].RootFS.Layers|.[]') | |
echo "base sha:$basesha repo sha:$reposha" | |
${{ github.event.inputs.buildtype == 'force' }} && echo "images=true" >> $GITHUB_OUTPUT || echo "no force" | |
[[ $reposha == *$basesha* ]] && echo "no changes" || echo "images=true" >> $GITHUB_OUTPUT | |
images: | |
needs: compare | |
if: ${{ needs.compare.outputs.images }} | |
runs-on: ubuntu-latest | |
outputs: | |
manifests: ${{ steps.manifests.outputs.manifests }} | |
strategy: | |
fail-fast: false | |
matrix: | |
arch: [amd64, arm, arm64] | |
version: [3.12, 3.14, 3.16, 3.18] | |
env: | |
name: "treehouses/alpine" | |
steps: | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: container registries | |
run: | | |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
docker login docker.io -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }} | |
- name: docker image | |
id: manifests | |
run: | | |
export DOCKER_CLI_EXPERIMENTAL=enabled | |
tags="$name-tags" | |
repo="$tags:${{ matrix.arch }}" | |
more="$repo-${{ matrix.version }}" | |
case ${{ matrix.arch }} in | |
amd64) : "amd64/alpine:${{ matrix.version }}" ;; | |
arm) : "balenalib/raspberry-pi-alpine:${{ matrix.version }}" ;; | |
arm64) : "arm64v8/alpine:${{ matrix.version }}" ;; | |
esac | |
base="$_" | |
time=$(date +%Y%m%d%H%M) | |
date="$repo-$time" | |
full="$more-$time" | |
docker build -t image --build-arg BASE=$base . | |
#for compatilbity reasons | |
if [[ "${{ matrix.version }}" == "3.12" ]]; then | |
docker tag image ghcr.io/$repo | |
docker tag image docker.io/$repo | |
docker tag image ghcr.io/$date | |
docker tag image docker.io/$date | |
fi | |
docker tag image ghcr.io/$more | |
docker tag image docker.io/$more | |
docker tag image ghcr.io/$full | |
docker tag image docker.io/$full | |
docker push --all-tags ghcr.io/$tags | |
docker push --all-tags docker.io/$tags | |
docker images | |
echo "manifests=true" >> $GITHUB_OUTPUT | |
manifests: | |
needs: images | |
if: ${{ needs.images.outputs.manifests }} | |
strategy: | |
fail-fast: false | |
matrix: | |
registry: [docker.io, ghcr.io] | |
version: [3.12, 3.14, 3.16, 3.18] | |
runs-on: ubuntu-latest | |
outputs: | |
message: ${{ steps.message.outputs.message }} | |
env: | |
name: "${{ matrix.registry }}/treehouses/alpine" | |
steps: | |
- name: container registries | |
run: | | |
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
docker login docker.io -u ${{ secrets.DOCKERUSERNAME }} -p ${{ secrets.DOCKERAPIKEY }} | |
- name: create manifests | |
id: message | |
run: | | |
export DOCKER_CLI_EXPERIMENTAL=enabled | |
tags="$name-tags" | |
date="$(date +%Y%m%d%H%M)" | |
#for compatilbity reasons | |
if [[ "${{ matrix.version }}" == "3.12" ]]; then | |
docker manifest create $name:latest $tags:amd64 $tags:arm $tags:arm64 | |
docker manifest annotate $name:latest $tags:arm --os linux --arch arm | |
docker manifest inspect $name:latest | |
docker manifest push $name:latest | |
docker manifest create $name:$date $tags:amd64 $tags:arm $tags:arm64 | |
docker manifest annotate $name:$date $tags:arm --os linux --arch arm | |
docker manifest inspect $name:$date | |
docker manifest push $name:$date | |
fi | |
docker manifest create $name:${{ matrix.version }} $tags:amd64-${{ matrix.version }} $tags:arm-${{ matrix.version }} $tags:arm64-${{ matrix.version }} | |
docker manifest annotate $name:${{ matrix.version }} $tags:arm-${{ matrix.version }} --os linux --arch arm | |
docker manifest inspect $name:${{ matrix.version }} | |
docker manifest push $name:${{ matrix.version }} | |
docker manifest create $name:${{ matrix.version }}-$date $tags:amd64-${{ matrix.version }} $tags:arm-${{ matrix.version }} $tags:arm64-${{ matrix.version }} | |
docker manifest annotate $name:${{ matrix.version }}-$date $tags:arm-${{ matrix.version }} --os linux --arch arm | |
docker manifest inspect $name:${{ matrix.version }}-$date | |
docker manifest push $name:${{ matrix.version }}-$date | |
echo "message=true" >> $GITHUB_OUTPUT | |
message: | |
needs: manifests | |
if: ${{ needs.manifests.outputs.message }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: message chat of new image | |
run: | | |
sudo npm install -g @treehouses/cli | |
export discord_channel="${{ secrets.CHANNEL }}" | |
echo "https://hub.docker.com/r/treehouses/alpine/tags" | |
echo "https://github.com/treehouses/alpine/pkgs/container/alpine" | |
treehouses feedback "new treehouses/alpine check https://hub.docker.com/r/treehouses/alpine/tags or https://github.com/treehouses/alpine/pkgs/container/alpine" |