2020-05-01 17:44:56 +02:00
|
|
|
|
|
|
|
name: Build DockerHub
|
|
|
|
on:
|
|
|
|
push:
|
2020-08-21 10:54:24 +02:00
|
|
|
branches:
|
2020-08-21 11:55:07 +02:00
|
|
|
- '*'
|
2020-08-21 10:54:24 +02:00
|
|
|
tags:
|
|
|
|
- '*'
|
2021-06-24 17:30:16 +02:00
|
|
|
paths:
|
|
|
|
- '**.sh'
|
|
|
|
- "Dockerfile"
|
|
|
|
- '.github/workflows/dockerhub.yml'
|
|
|
|
|
2022-08-18 14:30:11 +02:00
|
|
|
concurrency:
|
2022-08-23 16:15:50 +02:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
2022-08-18 14:30:11 +02:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
|
2020-05-01 17:44:56 +02:00
|
|
|
jobs:
|
2020-09-08 16:44:43 +02: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
|
2023-01-28 09:24:27 +01:00
|
|
|
echo "hasToken=true" >>$GITHUB_OUTPUT
|
2020-09-08 16:44:43 +02:00
|
|
|
else
|
2023-01-28 09:24:27 +01:00
|
|
|
echo "hasToken=false" >>$GITHUB_OUTPUT
|
2020-09-08 16:44:43 +02:00
|
|
|
fi
|
|
|
|
- name: Check the value
|
|
|
|
run: echo ${{ steps.step_one.outputs.hasToken }}
|
|
|
|
|
2020-05-01 17:44:56 +02:00
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
2020-09-08 16:44:43 +02:00
|
|
|
needs: CheckToken
|
|
|
|
if: "contains(needs.CheckToken.outputs.hasToken, 'true')"
|
2020-05-01 17:44:56 +02:00
|
|
|
steps:
|
2020-07-23 14:53:53 +02:00
|
|
|
- name: checkout code
|
2023-11-20 23:39:25 +01:00
|
|
|
uses: actions/checkout@v4
|
2021-01-26 15:10:53 +01:00
|
|
|
- name: Set up QEMU
|
2023-01-29 04:13:23 +01:00
|
|
|
uses: docker/setup-qemu-action@v2
|
2021-01-26 15:10:53 +01:00
|
|
|
- name: Set up Docker Buildx
|
2023-01-29 04:13:23 +01:00
|
|
|
uses: docker/setup-buildx-action@v2
|
2020-07-23 14:53:53 +02:00
|
|
|
- name: login to docker hub
|
|
|
|
run: |
|
|
|
|
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
|
2020-08-21 10:54:24 +02:00
|
|
|
- name: build and push the image
|
2020-07-24 10:25:58 +02:00
|
|
|
run: |
|
2020-08-21 11:40:13 +02:00
|
|
|
DOCKER_IMAGE=neilpang/acme.sh
|
2020-08-21 11:34:43 +02:00
|
|
|
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
2020-08-21 11:55:07 +02:00
|
|
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/tags/}
|
2020-08-21 11:34:43 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $GITHUB_REF == refs/heads/* ]]; then
|
2020-08-21 11:55:07 +02:00
|
|
|
DOCKER_IMAGE_TAG=${GITHUB_REF#refs/heads/}
|
2020-08-21 11:34:43 +02:00
|
|
|
|
2020-08-21 11:55:07 +02:00
|
|
|
if [[ $DOCKER_IMAGE_TAG == master ]]; then
|
|
|
|
DOCKER_IMAGE_TAG=latest
|
2020-08-21 11:34:43 +02:00
|
|
|
AUTO_UPGRADE=1
|
|
|
|
fi
|
|
|
|
fi
|
2020-08-21 10:54:24 +02:00
|
|
|
|
2020-07-24 10:25:58 +02:00
|
|
|
docker buildx build \
|
2020-08-21 11:55:07 +02:00
|
|
|
--tag ${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG} \
|
2020-08-21 10:54:24 +02:00
|
|
|
--output "type=image,push=true" \
|
|
|
|
--build-arg AUTO_UPGRADE=${AUTO_UPGRADE} \
|
2020-11-05 01:25:07 +01:00
|
|
|
--platform linux/arm64/v8,linux/amd64,linux/arm/v6,linux/arm/v7,linux/386,linux/ppc64le,linux/s390x .
|