fix pushing images to docker.io

pull/594/head
snpz 2024-01-10 17:55:12 +01:00 zatwierdzone przez Andrew Gaul
rodzic ea9fb9fd30
commit 40bdb6c1f9
1 zmienionych plików z 14 dodań i 27 usunięć

Wyświetl plik

@ -6,34 +6,33 @@ on:
pull_request: pull_request:
branches: branches:
- "*" - "*"
env:
dockerhub_publish: ${{ secrets.DOCKER_PASS != '' }}
jobs: jobs:
meta: meta:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
dockerhub-publish: ${{ steps.dockerhub-publish.outputs.defined }}
registry: ghcr.io/${{ github.repository }}/container:${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.version'] }}
container_tags: ${{ steps.docker_action_meta.outputs.tags }} container_tags: ${{ steps.docker_action_meta.outputs.tags }}
container_labels: ${{ steps.docker_action_meta.outputs.labels }} container_labels: ${{ steps.docker_action_meta.outputs.labels }}
container_buildtime: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.created'] }} container_buildtime: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.created'] }}
container_version: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.version'] }} container_version: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.version'] }}
container_revision: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.revision'] }} container_revision: ${{ fromJSON(steps.docker_action_meta.outputs.json).labels['org.opencontainers.image.revision'] }}
container_base: ${{ fromJSON(steps.docker_action_meta.outputs.json).tags[0] }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
submodules: false submodules: false
persist-credentials: false persist-credentials: false
- id: dockerhub-publish
if: "${{ env.MY_KEY != '' }}"
run: echo "::set-output name=defined::true"
env:
MY_KEY: ${{ secrets.DOCKER_PASS }}
- name: Docker meta - name: Docker meta
id: docker_action_meta id: docker_action_meta
uses: docker/metadata-action@v4.0.1 uses: docker/metadata-action@v4.0.1
with: with:
images: ghcr.io/${{ github.repository }}/container images:
name=ghcr.io/${{ github.repository }}/container
name=andrewgaul/s3proxy,enable=${{ env.dockerhub_publish }}
flavor: | flavor: |
latest=false latest=false
tags: | tags: |
@ -103,17 +102,17 @@ jobs:
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Login to DockerHub - name: Login to DockerHub
uses: docker/login-action@v2.0.0 uses: docker/login-action@v3
if: github.event_name != 'pull_request' && needs.meta.outputs.dockerhub-publish == 'true' if: github.event_name != 'pull_request' && env.dockerhub_publish == 'true'
with: with:
username: ${{ secrets.DOCKER_USER }} username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }} password: ${{ secrets.DOCKER_PASS }}
- name: Login to GHCR - name: Login to GHCR
uses: docker/login-action@v2.0.0 uses: docker/login-action@v3
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
with: with:
registry: ghcr.io registry: ghcr.io
@ -121,26 +120,14 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push - name: Build and push
uses: docker/build-push-action@v3 uses: docker/build-push-action@v5
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: ${{ needs.meta.outputs.container_base }} tags: ${{ needs.meta.outputs.container_tags }}
labels: ${{ needs.meta.outputs.container_labels }} labels: ${{ needs.meta.outputs.container_labels }}
build-args: | build-args: |
BUILDTIME=${{ needs.meta.outputs.container_buildtime }} BUILDTIME=${{ needs.meta.outputs.container_buildtime }}
VERSION=${{ needs.meta.outputs.container_version }} VERSION=${{ needs.meta.outputs.container_version }}
REVISION=${{ needs.meta.outputs.container_revision }} REVISION=${{ needs.meta.outputs.container_revision }}
cache-from: type=registry,ref=${{ needs.meta.outputs.container_base }}
cache-to: type=inline
- name: Publish to Docker
if: github.event_name != 'pull_request' && needs.meta.outputs.dockerhub-publish == 'true'
run: |
curl -L https://github.com/regclient/regclient/releases/download/v0.3.5/regctl-linux-amd64 >/tmp/regctl
chmod 755 /tmp/regctl
for line in $CONTAINER_DEST_TAGS; do echo working on "$line"; /tmp/regctl image copy $SOURCE_CONTAINER $line; done
env:
SOURCE_CONTAINER: ${{ needs.meta.outputs.container_version }}
CONTAINER_DEST_TAGS: ${{ needs.meta.outputs.container_tags }}