Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parallelization #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions .github/workflows/apache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: build on change

on:
push:
branches:
- master
- main
workflow_dispatch:
repository_dispatch:
types: apache

jobs:
compare:
runs-on: ubuntu-latest
outputs:
flag: ${{ steps.set-flag.outputs.flag }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the 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: Compare images for changes
id: set-flag
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
repo="treehouses/apache-tags:${{ matrix.arch }}"
base="treehouses/debian-tags:${{ matrix.arch }}"
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"
[[ $reposha == *$basesha* ]] && echo "no changes" || echo "::set-output name=flag::true"
images:
needs: compare
runs-on: ubuntu-latest
outputs:
build: ${{ steps.set-build.outputs.build }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm, arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Log in to the 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: Build docker image
if: ${{ needs.compare.outputs.flag }}
id: set-build
run: |
export DOCKER_CLI_EXPERIMENTAL=enabled
echo "**************0*************"
base="treehouses/debian-tags:${{ matrix.arch }}"
repo="treehouses/apache-tags:${{ matrix.arch }}"
date="$(date +%Y%m%d%H%M)"
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker build -t ghcr.io/$repo --build-arg BASE=$base .
docker tag ghcr.io/$repo docker.io/$repo
docker tag ghcr.io/$repo ghcr.io/$repo-$date
docker tag docker.io/$repo docker.io/$repo-$date
docker push ghcr.io/$repo
docker push docker.io/$repo
docker push ghcr.io/$repo-$date
docker push docker.io/$repo-$date
docker images
echo "::set-output name=build::true"
manifests:
needs: images
strategy:
fail-fast: false
matrix:
registry: [docker.io, ghcr.io]
runs-on: ubuntu-latest
steps:

- name: Log in to the 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: Deploying manifest to Container Registries
if: ${{ needs.images.outputs.build }}
run: |
repo="${{ matrix.registry }}/treehouses/apache"
date="$(date +%Y%m%d%H%M)"
docker manifest create $repo:latest $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest create $repo:$date $repo-tags:amd64 $repo-tags:arm $repo-tags:arm64
docker manifest annotate $repo:latest $repo-tags:arm --os linux --arch arm
docker manifest annotate $repo:$date $repo-tags:arm --os linux --arch arm
docker manifest inspect $repo:latest
docker manifest push $repo:latest
docker manifest push $repo:$date
60 changes: 0 additions & 60 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion Dockerfile.template → Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM {{base_image}}
ARG BASE=
FROM ${BASE}

RUN apt-get update -y && apt-get install -y apache2

Expand Down
118 changes: 0 additions & 118 deletions utils.sh

This file was deleted.