-
Notifications
You must be signed in to change notification settings - Fork 18
171 lines (153 loc) · 5.77 KB
/
dockerhub.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
name: Build docker images
on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'Dockerfile'
- 'Dockerfile-test'
- 'Dockerfile-dev'
- 'Dockerfile-generator'
- '.github/workflows/dockerhub.yml'
jobs:
build-publish:
name: Build & Publish Docker Images
runs-on: ubuntu-latest
env:
GENERATOR_IMAGE_NAME: decidim/decidim-generator
TEST_IMAGE_NAME: decidim/decidim-test
DEV_IMAGE_NAME: decidim/decidim-dev
APP_IMAGE_NAME: decidim/decidim
TAG: ${{ github.sha }}
steps:
- name: Fetch Decidim Tag
id: decidim-tag
uses: oprypin/find-latest-tag@v1
with:
repository: decidim/decidim
releases-only: true
- name: Set Ruby Version
id: ruby-version
env:
RUBY_VERSION_URL: https://raw.githubusercontent.com/decidim/decidim/${{ steps.decidim-tag.outputs.tag }}/.ruby-version
run: |
echo ::set-output name=version::$(curl -s $RUBY_VERSION_URL)
- name: Set Decidim Version
id: decidim-version
run: echo ::set-output name=version::$(echo ${{ steps.decidim-tag.outputs.tag }} | cut -c2-)
- name: Checkout Our Repo
uses: actions/checkout@v2
- name: Build decidim-generator Image
env:
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
run: |
docker build \
--build-arg ruby_version=$RUBY_VERSION \
--build-arg decidim_version=$DECIDIM_VERSION \
--file Dockerfile-generator \
-t $GENERATOR_IMAGE_NAME .
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$TAG
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$TAG
docker tag $GENERATOR_IMAGE_NAME $GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
docker tag $GENERATOR_IMAGE_NAME ghcr.io/$GENERATOR_IMAGE_NAME:$DECIDIM_VERSION
- name: Publish decidim-generator Image to Docker Hub
uses: docker/login-action@v1
with:
username: decidimbot
password: ${{ secrets.DOCKERHUB_PAT }}
- run: |
docker push --all-tags $GENERATOR_IMAGE_NAME
- name: Publish decidim-generator Image to GitHub Registry
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: decidim-bot
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- run: |
docker push --all-tags ghcr.io/$GENERATOR_IMAGE_NAME
- name: Build decidim-test Image
env:
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
run: |
docker build \
--build-arg base_image=ghcr.io/$GENERATOR_IMAGE_NAME:$TAG \
--build-arg decidim_version=$DECIDIM_VERSION \
--file Dockerfile-test \
-t $TEST_IMAGE_NAME .
docker tag $TEST_IMAGE_NAME $TEST_IMAGE_NAME:$TAG
docker tag $TEST_IMAGE_NAME $TEST_IMAGE_NAME:$DECIDIM_VERSION
docker tag $TEST_IMAGE_NAME ghcr.io/$TEST_IMAGE_NAME:$TAG
docker tag $TEST_IMAGE_NAME ghcr.io/$TEST_IMAGE_NAME:$DECIDIM_VERSION
- name: Publish decidim-test Image to Docker Hub
uses: docker/login-action@v1
with:
username: decidimbot
password: ${{ secrets.DOCKERHUB_PAT }}
- run: |
docker push --all-tags $TEST_IMAGE_NAME
- name: Publish decidim-test Image to GitHub Registry
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: decidim-bot
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- run: |
docker push --all-tags ghcr.io/$TEST_IMAGE_NAME
- name: Build decidim-dev Image
env:
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
run: |
docker build \
--build-arg base_image=ghcr.io/$TEST_IMAGE_NAME:$TAG \
--file Dockerfile-dev \
-t $DEV_IMAGE_NAME .
docker tag $DEV_IMAGE_NAME $DEV_IMAGE_NAME:$TAG
docker tag $DEV_IMAGE_NAME $DEV_IMAGE_NAME:$DECIDIM_VERSION
docker tag $DEV_IMAGE_NAME ghcr.io/$DEV_IMAGE_NAME:$TAG
docker tag $DEV_IMAGE_NAME ghcr.io/$DEV_IMAGE_NAME:$DECIDIM_VERSION
- name: Publish decidim-dev Image to Docker Hub
uses: docker/login-action@v1
with:
username: decidimbot
password: ${{ secrets.DOCKERHUB_PAT }}
- run: |
docker push --all-tags $DEV_IMAGE_NAME
- name: Publish decidim-dev Image to GitHub Registry
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: decidim-bot
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- run: |
docker push --all-tags ghcr.io/$DEV_IMAGE_NAME
- name: Build decidim (app) Image
env:
RUBY_VERSION: ${{ steps.ruby-version.outputs.version }}
DECIDIM_VERSION: ${{ steps.decidim-version.outputs.version }}
run: |
docker build \
--build-arg base_image=ghcr.io/$GENERATOR_IMAGE_NAME:$TAG \
-t $APP_IMAGE_NAME .
docker tag $APP_IMAGE_NAME $APP_IMAGE_NAME:$TAG
docker tag $APP_IMAGE_NAME $APP_IMAGE_NAME:$DECIDIM_VERSION
docker tag $APP_IMAGE_NAME ghcr.io/$APP_IMAGE_NAME:$TAG
docker tag $APP_IMAGE_NAME ghcr.io/$APP_IMAGE_NAME:$DECIDIM_VERSION
- name: Publish decidim Image to Docker Hub
uses: docker/login-action@v1
with:
username: decidimbot
password: ${{ secrets.DOCKERHUB_PAT }}
- run: |
docker push --all-tags $APP_IMAGE_NAME
- name: Publish decidim Image to GitHub Registry
uses: azure/docker-login@v1
with:
login-server: ghcr.io
username: decidim-bot
password: ${{ secrets.CONTAINER_REGISTRY_PAT }}
- run: |
docker push --all-tags ghcr.io/$APP_IMAGE_NAME