-
Notifications
You must be signed in to change notification settings - Fork 20
76 lines (68 loc) · 2.2 KB
/
main.yaml
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
name: Push image
on:
push:
branches:
- main
jobs:
push:
permissions:
contents: read
packages: write
runs-on: ubuntu-latest
env:
IMAGE_NAME: ${{ github.repository }}
token: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@v3.5.2
- name: Log in to Github container registry
uses: docker/login-action@v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log in to Docker Hub
uses: docker/login-action@v2.1.0
if: ${{ env.token != '' }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Github Packages
id: meta_github
uses: docker/metadata-action@v4.3.0
with:
images: ghcr.io/${{ github.actor }}/${{ env.IMAGE_NAME }}
flavor: latest=true
tags: |
type=semver,pattern={{ version }}
type=ref,event=tag
type=sha
type=raw,value=latest,enable={{ is_default_branch }}
- name: Extract metadata (tags, labels) for Docker Hub
if: ${{ env.token != '' }}
id: meta_docker
uses: docker/metadata-action@v4.3.0
with:
images: clauten/${{ env.IMAGE_NAME }}
flavor: latest=true
tags: |
type=semver,pattern={{ version }}
type=ref,event=tag
type=sha
type=raw,value=latest,enable={{ is_default_branch }}
- name: Build and push image to Github Packages
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta_github.outputs.tags }}
labels: ${{ steps.meta_github.outputs.labels }}
- name: Build and push image to Docker Hub
uses: docker/build-push-action@v4.0.0
if: ${{ env.token != '' }}
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta_docker.outputs.tags }}
labels: ${{ steps.meta_docker.outputs.labels }}