forked from pengzhile/pandora
-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (74 loc) · 2.49 KB
/
docker-publish.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Push Docker Image
on:
workflow_dispatch:
release:
types: [ published ]
permissions:
packages: write
contents: read
env:
IMAGE_NAME: pandora
PLATFORMS: linux/amd64,linux/arm64
jobs:
get-tags:
runs-on: ubuntu-latest
outputs:
image_version: ${{ steps.get_image_version.outputs.image_version }}
steps:
- uses: actions/checkout@v3
- name: Get Image Version
id: get_image_version
run: |
# Strip git ref prefix from version
IMAGE_VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && IMAGE_VERSION=$(echo $IMAGE_VERSION | sed -e 's/^v//')
echo VERSION=$IMAGE_VERSION
echo "image_version=${IMAGE_VERSION}" >> $GITHUB_OUTPUT
push-ghcr:
needs: get-tags
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
steps:
- uses: actions/checkout@v3
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
platforms: ${{ env.PLATFORMS }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ needs.get-tags.outputs.image_version }}
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest
push-docker-hub:
needs: get-tags
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker Setup QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v2
- name: Docker Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v4
with:
push: true
platforms: ${{ env.PLATFORMS }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:${{ needs.get-tags.outputs.image_version }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:latest