-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.5 KB
/
docker-image-sync.yml
File metadata and controls
53 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Docker Image Sync
on:
workflow_dispatch:
inputs:
origin-registry:
description: Original Registry
type: choice
options:
- docker.io
- ghcr.io
default: docker.io
image-name:
description: 'Docker Image'
required: true
jobs:
build-and-upload:
runs-on: ubuntu-latest
environment: AliDocker
env:
ORIGIN_REGISTRY: ${{ github.event.inputs.origin-registry }}
REGISTRY: ${{ vars.REGISTRY }}
REGISTRY_REPO: ${{ vars.REGISTRY_REPO }}
steps:
- name: Update Image Name
env:
DOCKER_IMAGE: ${{ github.event.inputs.image-name }}
run: |
if [ "${DOCKER_IMAGE//\//}" == "${DOCKER_IMAGE}" ]; then
echo "DOCKER_IMAGE=library/${DOCKER_IMAGE}" >> $GITHUB_ENV
echo "IMAGE_NAME=${DOCKER_IMAGE}" >> $GITHUB_ENV
else
echo "DOCKER_IMAGE=${DOCKER_IMAGE}" >> $GITHUB_ENV
echo "IMAGE_NAME=${DOCKER_IMAGE##*/}" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Use Skopeo Tools Sync Image to Docker Hub
run: |
skopeo copy docker://${{ env.ORIGIN_REGISTRY }}/${{ env.DOCKER_IMAGE }} docker://${{ env.REGISTRY }}/${{ env.REGISTRY_REPO }}/${{ env.IMAGE_NAME }}