-
-
Notifications
You must be signed in to change notification settings - Fork 238
71 lines (67 loc) · 2.58 KB
/
mirror-docker-image.yml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
name: Mirror docker image
on:
workflow_dispatch:
inputs:
source-image:
description: 'Source of the image on ghcr.io'
required: true
target-image:
description: 'Target of the image hosted on docker hub'
required: true
free-space-before:
description: 'Free space on the runner before pulling and pushing docker image'
required: false
default: 'true'
jobs:
copy-to-docker-hub-alpha:
if: github.ref_name == 'alpha'
runs-on: ubuntu-latest
environment:
name: alpha
steps:
# Free disk space
- name: Free Disk space
if: github.event.inputs.free-space-before == 'true'
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
# Login to docker hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Copy ghrc.io image to Docker Hub
- name: Pull image from GHCR
run: docker pull "${{ github.event.inputs.source-image }}"
- name: Tag image for Docker Hub
run: docker tag "${{ github.event.inputs.source-image }}" "${{ github.event.inputs.target-image }}"
- name: Push image to Docker Hub
run: docker push "${{ github.event.inputs.target-image }}"
copy-to-docker-hub-main:
if: github.ref_name == 'main' || startsWith(github.ref_name, 'v')
runs-on: ubuntu-latest
environment:
name: beta
steps:
# Free disk space
- name: Free Disk space
if: github.event.inputs.free-space-before == 'true'
shell: bash
run: |
sudo rm -rf /usr/local/lib/android # will release about 10 GB if you don't need Android
sudo rm -rf /usr/share/dotnet # will release about 20GB if you don't need .NET
# Login to docker hub
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Copy ghrc.io image to Docker Hub
- name: Pull image from GHCR
run: docker pull "${{ github.event.inputs.source-image }}"
- name: Tag image for Docker Hub
run: docker tag "${{ github.event.inputs.source-image }}" "${{ github.event.inputs.target-image }}"
- name: Push image to Docker Hub
run: docker push "${{ github.event.inputs.target-image }}"