Skip to content

Commit

Permalink
feat(ci): add action to build containers on tag
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Feb 19, 2021
1 parent 6b42c0e commit d85cab5
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/release-containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Release Containers

on:
push:
tags: [ 'v*' ]


jobs:
release-containers:
name: Build and Push
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Login to ghcr.io Docker registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Compute Docker container image addresses
run: |
DOCKER_REPOSITORY="ghcr.io/${GITHUB_REPOSITORY,,}"
DOCKER_TAG="${GITHUB_REF:11}"
echo "DOCKER_REPOSITORY=${DOCKER_REPOSITORY}" >> $GITHUB_ENV
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV
echo "Using: ${DOCKER_REPOSITORY}/*:${DOCKER_TAG}"
- name: 'Pull latest existing Docker container image: backend'
run: docker pull "${DOCKER_REPOSITORY}/backend:latest" || true

- name: 'Pull latest existing Docker container image: frontend'
run: docker pull "${DOCKER_REPOSITORY}/frontend:latest" || true

- name: 'Build Docker container image: backend'
run: |
docker build \
--cache-from "${DOCKER_REPOSITORY}/backend:latest" \
--tag "${DOCKER_REPOSITORY}/backend:latest" \
--tag "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}" \
.
- name: 'Build Docker container image: frontend'
run: |
docker build \
--cache-from "${DOCKER_REPOSITORY}/frontend:latest" \
--tag "${DOCKER_REPOSITORY}/frontend:latest" \
--tag "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}" \
frontend
- name: Push Docker container image frontend:v*"
run: docker push "${DOCKER_REPOSITORY}/frontend:${DOCKER_TAG}"

- name: Push Docker container image frontend:latest"
run: docker push "${DOCKER_REPOSITORY}/frontend:latest"

- name: Push Docker container image backend:v*"
run: docker push "${DOCKER_REPOSITORY}/backend:${DOCKER_TAG}"

- name: Push Docker container image backend:latest"
run: docker push "${DOCKER_REPOSITORY}/backend:latest"

0 comments on commit d85cab5

Please sign in to comment.