Skip to content

Commit d85cab5

Browse files
feat(ci): add action to build containers on tag
1 parent 6b42c0e commit d85cab5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Release Containers
2+
3+
on:
4+
push:
5+
tags: [ 'v*' ]
6+
7+
8+
jobs:
9+
release-containers:
10+
name: Build and Push
11+
runs-on: ubuntu-latest
12+
steps:
13+
14+
- uses: actions/checkout@v2
15+
16+
- name: Login to ghcr.io Docker registry
17+
uses: docker/login-action@v1
18+
with:
19+
registry: ghcr.io
20+
username: ${{ github.repository_owner }}
21+
password: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- name: Compute Docker container image addresses
24+
run: |
25+
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
26+
DOCKER_TAG="${GITHUB_REF:11}"
27+
28+
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
29+
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
30+
31+
echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"
32+
33+
- name: 'Pull latest existing Docker container image: backend'
34+
run: docker pull "${DOCKER_REPOSITORY}/backend:latest" || true
35+
36+
- name: 'Pull latest existing Docker container image: frontend'
37+
run: docker pull "${DOCKER_REPOSITORY}/frontend:latest" || true
38+
39+
- name: 'Build Docker container image: backend'
40+
run: |
41+
docker build \
42+
--cache-from "${DOCKER_REPOSITORY}/backend:latest" \
43+
--tag "${DOCKER_REPOSITORY}/backend:latest" \
44+
--tag "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}" \
45+
.
46+
47+
- name: 'Build Docker container image: frontend'
48+
run: |
49+
docker build \
50+
--cache-from "${DOCKER_REPOSITORY}/frontend:latest" \
51+
--tag "${DOCKER_REPOSITORY}/frontend:latest" \
52+
--tag "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}" \
53+
frontend
54+
55+
- name: Push Docker container image frontend:v*"
56+
run: docker push "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}"
57+
58+
- name: Push Docker container image frontend:latest"
59+
run: docker push "${DOCKER_REPOSITORY}/frontend:latest"
60+
61+
- name: Push Docker container image backend:v*"
62+
run: docker push "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}"
63+
64+
- name: Push Docker container image backend:latest"
65+
run: docker push "${DOCKER_REPOSITORY}/backend:latest"

0 commit comments

Comments
 (0)