Skip to content

Commit

Permalink
feat(ci): improve docker build ci
Browse files Browse the repository at this point in the history
  • Loading branch information
simonostendorf committed Aug 18, 2023
1 parent 126b9d4 commit 451cc1c
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ changelog:
- deprecated
- title: Other Changes
labels:
- "*"
- "*"
27 changes: 0 additions & 27 deletions .github/workflows/docker-dev.yml

This file was deleted.

51 changes: 39 additions & 12 deletions .github/workflows/docker-release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,55 @@
name: Docker CI (release)
name: Docker Release

on:
release:
types: [published]
types:
- published
push:
branches:
- dev

env:
REGISTRY: ghcr.io
IMAGE_REGISTRY: ghcr.io
IMAGE_PATH: ${{ github.repository }}
IMAGE_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Log into registry ${{ env.REGISTRY }}
- name: Get latest release
id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker
run: |
docker build -f ./Dockerfile . --tag ${{ env.REGISTRY }}/fsr5-fhaachen/portals:${{ env.RELEASE_VERSION }} --tag ${{ env.REGISTRY }}/fsr5-fhaachen/portals:latest
docker push ${{ env.REGISTRY }}/fsr5-fhaachen/portals:${{ env.RELEASE_VERSION }}
docker push ${{ env.REGISTRY }}/fsr5-fhaachen/portals:latest
- name: Build and push (latest release)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release == github.ref_name }} # run only on latest release
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:latest
- name: Build and push (release)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release != github.ref_name }} # run only on release (not latest)
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
- name: Build and push (push)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'push' }} # run only on push (to dev)
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}

0 comments on commit 451cc1c

Please sign in to comment.