Skip to content

Auto-update ccl

Auto-update ccl #59

name: Build new images
on:
pull_request:
branches:
- master
types:
- closed
jobs:
updated:
name: Check new versions
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
outputs:
versions: ${{ steps.extract-diff.outputs.versions }}
images: ${{ steps.extract-diff.outputs.images }}
steps:
- id: extract-diff
run: |
PR_FILES_URL="https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.number }}/files"
VERSIONS=$(curl -s "$PR_FILES_URL" \
| jq -rcM 'map(select(.filename | test("[^/]+/versions$")) | {(.filename | match("[^/]+") | .string): (.patch | split("\n") | map(select(. | test("^\\+")) | .[1:] | match("[^,]+") | .string))}) | add')
echo "::set-output name=versions::$VERSIONS"
echo "::set-output name=images::$(echo "$VERSIONS" | jq -Mc 'to_entries | map(.key)')"
build_images:
name: Build ${{ matrix.target }}
needs: updated
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
strategy:
matrix:
target: ${{ fromJSON(needs.updated.outputs.images) }}
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: fukamachi
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Build and publish image
env:
IMAGE: ${{ matrix.target }}
run: |
case "$IMAGE" in
roswell)
ARCH=linux/amd64,linux/arm64
;;
*)
ARCH=linux/amd64
;;
esac
VERSIONS=($(echo '${{ needs.updated.outputs.versions }}' | jq -rc ".$IMAGE" | tr -d '[]"' | sed -e 's/,/ /g'))
OS=("debian" "ubuntu" "alpine")
for version in "${VERSIONS[@]}"; do
for os in "${OS[@]}"; do
BUILD_ARGS=--push ARCH="$ARCH" ./build.sh "$IMAGE" "$version" "$os"
done
done