1+ ---
2+ name : ' build images'
3+
4+ on :
5+ push :
6+ branches :
7+ - master
8+
9+ jobs :
10+ docker :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout
14+ uses : actions/checkout@v2
15+
16+ - name : Prepare
17+ id : prep
18+ run : |
19+ DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/}
20+ VERSION=latest
21+ # SHORTREF=${GITHUB_SHA::8}
22+
23+ # If this is git tag, use the tag name as a docker tag
24+ if [[ $GITHUB_REF == refs/tags/* ]]; then
25+ VERSION=${GITHUB_REF#refs/tags/v}
26+ TAGS="${DOCKER_IMAGE}:${VERSION}-alpine"
27+ fi
28+
29+ # If the VERSION looks like a version number, assume that
30+ # this is the most recent version of the image and also
31+ # tag it 'latest'.
32+ if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
33+ TAGS="$TAGS,${DOCKER_IMAGE}:latest"
34+ fi
35+
36+ # Set output parameters.
37+ echo ::set-output name=tags::${TAGS}
38+ echo ::set-output name=docker_image::${DOCKER_IMAGE}
39+
40+ - name : Set up QEMU
41+ uses : docker/setup-qemu-action@master
42+ with :
43+ platforms : all
44+
45+ - name : Set up Docker Buildx
46+ id : buildx
47+ uses : docker/setup-buildx-action@master
48+
49+ - name : Login to DockerHub
50+ if : github.event_name != 'pull_request'
51+ uses : docker/login-action@v1
52+ with :
53+ username : ${{ secrets.DOCKER_USERNAME }}
54+ password : ${{ secrets.DOCKER_PASSWORD }}
55+
56+ - name : Build
57+ uses : docker/build-push-action@v2
58+ with :
59+ builder : ${{ steps.buildx.outputs.name }}
60+ context : .
61+ file : ./Dockerfile
62+ platforms : linux/arm64,linux/ppc64le
63+ push : true
64+ tags : ${{ steps.prep.outputs.tags }}
0 commit comments