2020-05-01 15:44:56 +00:00
|
|
|
|
|
|
|
name: Build DockerHub
|
|
|
|
on:
|
|
|
|
push:
|
2020-08-21 08:54:24 +00:00
|
|
|
branches:
|
2020-08-21 09:55:07 +00:00
|
|
|
- '*'
|
2020-08-21 08:54:24 +00:00
|
|
|
tags:
|
|
|
|
- '*'
|
2020-05-01 15:44:56 +00:00
|
|
|
|
|
|
|
jobs:
|
2020-09-08 14:44:43 +00:00
|
|
|
CheckToken:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
hasToken: ${{ steps.step_one.outputs.hasToken }}
|
|
|
|
env:
|
|
|
|
DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
steps:
|
|
|
|
- name: Set the value
|
|
|
|
id: step_one
|
|
|
|
run: |
|
|
|
|
if [ "$DOCKER_PASSWORD" ] ; then
|
|
|
|
echo "::set-output name=hasToken::true"
|
|
|
|
else
|
|
|
|
echo "::set-output name=hasToken::false"
|
|
|
|
fi
|
|
|
|
- name: Check the value
|
|
|
|
run: echo ${{ steps.step_one.outputs.hasToken }}
|
|
|
|
|
2020-05-01 15:44:56 +00:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2020-09-08 14:44:43 +00:00
|
|
|
needs: CheckToken
|
|
|
|
if: "contains(needs.CheckToken.outputs.hasToken, 'true')"
|
2020-05-01 15:44:56 +00:00
|
|
|
steps:
|
2020-07-23 12:53:53 +00:00
|
|
|
- name: checkout code
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: install buildx
|
|
|
|
id: buildx
|
2020-08-21 08:54:24 +00:00
|
|
|
uses: crazy-max/ghaction-docker-buildx@v3
|
2020-07-23 12:53:53 +00:00
|
|
|
with:
|
2020-08-21 08:54:24 +00:00
|
|
|
buildx-version: latest
|
|
|
|
qemu-version: latest
|
2020-07-23 12:53:53 +00:00
|
|
|
- name: login to docker hub
|
|
|
|
run: |
|
|
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
2020-08-21 08:54:24 +00:00
|
|
|
- name: build and push the image
|
2020-07-24 08:25:58 +00:00
|
|
|
run: |
|
2020-08-21 09:40:13 +00:00
|
|
|
DOCKER_IMAGE=neilpang/acme.sh
|
2020-08-21 09:34:43 +00:00
|
|
|
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2020-08-21 09:55:07 +00:00
|
|
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
|
2020-08-21 09:34:43 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
2020-08-21 09:55:07 +00:00
|
|
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/heads/}
|
2020-08-21 09:34:43 +00:00
|
|
|
|
2020-08-21 09:55:07 +00:00
|
|
|
if [[ $DOCKER_IMAGE_TAG == master ]]; then
|
|
|
|
DOCKER_IMAGE_TAG=latest
|
2020-08-21 09:34:43 +00:00
|
|
|
AUTO_UPGRADE=1
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-21 08:54:24 +00:00
|
|
|
|
2020-07-24 08:25:58 +00:00
|
|
|
docker buildx build \
|
2020-08-21 09:55:07 +00:00
|
|
|
--tag ${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG} \
|
2020-08-21 08:54:24 +00:00
|
|
|
--output "type=image,push=true" \
|
|
|
|
--build-arg AUTO_UPGRADE=${AUTO_UPGRADE} \
|
2020-11-05 00:25:07 +00:00
|
|
|
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386,linux/ppc64le,linux/s390x .
|