mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-21 05:02:43 +00:00
109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
name: docker-images
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- docker-test
|
|
pull_request:
|
|
branches:
|
|
- master
|
|
- docker-test
|
|
|
|
jobs:
|
|
multi:
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
image:
|
|
- bandersnatch
|
|
- ftpsync
|
|
- nix-channels
|
|
- pub-mirror
|
|
- rustup-mirror
|
|
include:
|
|
- image: tunasync-scripts
|
|
dockerfile: .
|
|
- image: julia-mirror
|
|
dockerfile: dockerfiles/julia
|
|
- image: rubygems-mirror
|
|
dockerfile: dockerfiles/rubygems
|
|
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
-
|
|
name: Determin docker tag
|
|
env:
|
|
TAG_NAME: ${{ github.ref }}
|
|
run: |
|
|
if [ "${TAG_NAME##*/}" = "master" ]; then
|
|
tag=latest
|
|
else
|
|
tag=build-test
|
|
fi
|
|
echo "docker_tag=${tag}" >> $GITHUB_ENV
|
|
-
|
|
name: Determin dockerfile
|
|
env:
|
|
DF: ${{ matrix.dockerfile }}
|
|
IMG: ${{ matrix.image }}
|
|
run: |
|
|
if [ -z "${DF}" ]; then
|
|
DF="dockerfiles/${IMG}"
|
|
fi
|
|
echo "docker_file=${DF}" >> $GITHUB_ENV
|
|
-
|
|
name: Checkout
|
|
uses: actions/checkout@v3
|
|
-
|
|
name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
with:
|
|
platforms: arm64
|
|
-
|
|
name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
-
|
|
name: Cache Docker layers
|
|
uses: actions/cache@v3
|
|
if: github.event_name == 'push'
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-buildx-${{ matrix.image }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-buildx-${{ matrix.image }}-
|
|
-
|
|
name: Cache Docker layers
|
|
uses: actions/cache@v3
|
|
if: github.event_name == 'pull_request'
|
|
with:
|
|
path: /tmp/.buildx-cache
|
|
key: ${{ runner.os }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-${{ github.sha }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pr-${{ github.event.pull_request.head.user.login }}-buildx-${{ matrix.image }}-
|
|
${{ runner.os }}-buildx-${{ matrix.image }}-
|
|
-
|
|
name: Cache Docker layers
|
|
if: github.event_name != 'push' && github.event_name != 'pull_request'
|
|
run: |
|
|
echo "I do not know how to setup cache"
|
|
exit -1
|
|
-
|
|
name: Login to DockerHub
|
|
uses: docker/login-action@v2
|
|
if: github.event_name == 'push'
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
-
|
|
name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: ${{ env.docker_file }}/Dockerfile
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name == 'push' }}
|
|
tags: tunathu/${{ matrix.image }}:${{ env.docker_tag }}
|
|
cache-from: type=local,src=/tmp/.buildx-cache
|
|
cache-to: type=local,dest=/tmp/.buildx-cache
|