Merge pull request #140 from Zoey2936/master

also push images to ghcr
This commit is contained in:
El RIDO 2023-02-25 09:17:50 +01:00 committed by GitHub
commit adc93d6675
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 13 deletions

View file

@ -29,8 +29,18 @@ jobs:
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Login to DockerHub
uses: docker/login-action@v2
if: (github.ref != 'refs/heads/master' && github.event_name != 'pull_request') || github.event_name == 'schedule'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
if: (github.ref != 'refs/heads/master' && github.event_name != 'pull_request') || github.event_name == 'schedule'
with:
registry: ghcr.io
username: privatebin
password: ${{ github.token }}
- name: Docker Build
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ./buildx.sh ${{ github.event_name }} ${{ matrix.destination-image }} ${{ matrix.base-image }}

View file

@ -31,12 +31,6 @@ push_image() {
.
}
docker_login() {
printenv DOCKER_PASSWORD | docker login \
--username "${DOCKER_USERNAME}" \
--password-stdin
}
is_image_push_required() {
[ "${EVENT}" != pull_request ] && { \
[ "${GITHUB_REF}" != refs/heads/master ] || \
@ -71,7 +65,7 @@ main() {
;;
esac
IMAGE="privatebin/${IMAGE}"
IMAGE_TAGS="--tag ${IMAGE}:latest --tag ${IMAGE}:${TAG} --tag ${IMAGE}:${TAG%%-*}"
IMAGE_TAGS="--tag ${IMAGE}:latest --tag ${IMAGE}:${TAG} --tag ${IMAGE}:${TAG%%-*} --tag ghcr.io/${IMAGE}:latest --tag ghcr.io/${IMAGE}:${TAG} --tag ghcr.io/${IMAGE}:${TAG%%-*}"
if [ "${EDGE}" = true ] ; then
# build from alpine:edge instead of the stable release
@ -79,12 +73,12 @@ main() {
BUILD_ARGS+=" -f Dockerfile.edge"
# replace the default tags, build just the edge one
IMAGE_TAGS="--tag ${IMAGE}:edge"
IMAGE_TAGS="--tag ${IMAGE}:edge --tag ghcr.io/${IMAGE}:edge"
IMAGE+=":edge"
else
if [ "${EVENT}" = push ] ; then
# append the stable tag on explicit pushes to master or (git) tags
IMAGE_TAGS+=" --tag ${IMAGE}:stable"
IMAGE_TAGS+=" --tag ${IMAGE}:stable --tag ghcr.io/${IMAGE}:stable"
fi
# always build latest on non-edge builds
IMAGE+=":latest"
@ -102,7 +96,6 @@ main() {
docker stop smoketest
if is_image_push_required ; then
docker_login
push_image "${BUILD_ARGS} ${IMAGE_TAGS}"
fi