-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (94 loc) · 3.25 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
95
96
97
98
99
100
101
102
103
104
105
name: Publish Docker images
on:
push:
branches: main
workflow_dispatch:
inputs:
tag:
description: "The tag of release"
required: true
jobs:
push_base_image:
name: Push base Docker image to multiple registries
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Parse tag
# This step converts Grain tags into standard semver, i.e. grain-v1.2.3 -> v1.2.3
id: vars
if: ${{ github.event.inputs.tag }}
run: GITHUB_TAG=${{ github.event.inputs.tag }}; echo ::set-output name=tag::${GITHUB_TAG#grain-}
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
images: |
grainlang/grain
ghcr.io/grain-lang/grain
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=${{ steps.vars.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.vars.outputs.tag }}
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push_slim_image:
name: Push slim Docker image to multiple registries
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
- name: Parse tag
# This step converts Grain tags into standard semver, i.e. grain-v1.2.3 -> v1.2.3
id: vars
if: ${{ github.event.inputs.tag }}
run: GITHUB_TAG=${{ github.event.inputs.tag }}; echo ::set-output name=tag::${GITHUB_TAG#grain-}
- name: Docker meta
id: meta
uses: docker/[email protected]
with:
flavor: |
suffix=-slim,onlatest=true
images: |
grainlang/grain
ghcr.io/grain-lang/grain
tags: |
type=ref,event=branch
type=semver,pattern={{version}},value=${{ steps.vars.outputs.tag }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.vars.outputs.tag }}
- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Github Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push slim image
uses: docker/[email protected]
with:
context: .
file: Dockerfile-slim
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}