Skip to content

Commit

Permalink
Merge pull request #159 from svalinn/docker-build-tweak
Browse files Browse the repository at this point in the history
Add tags to docker images to prevent branches from overwriting Parastell docker images
  • Loading branch information
gonuke authored Sep 20, 2024
2 parents b8fd8c4 + c767cfc commit 3224b20
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ on:
- '.github/workflows/docker_publish.yml'
- 'environment.yml'

env:
EXTRA_TAG: ""
EXTRA_TAG_CI: ""

jobs:
build-dependency-img:
runs-on: ubuntu-latest

name: Install Dependencies

outputs:
image_tag: ${{ steps.output_tag.outputs.image_tag }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand All @@ -28,21 +36,30 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Add extra tag if NOT on the main branch
if: github.ref_name != 'main'
run: |
echo "EXTRA_TAG=-${{ github.ref_name }}" >> $GITHUB_ENV
echo "EXTRA_TAG_CI=:${{ github.ref_name }}" >> $GITHUB_ENV
- id: output_tag
run: echo "image_tag=$EXTRA_TAG_CI" >> $GITHUB_OUTPUT

- name: Build and push ParaStell Docker image
id: build-parastell
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/svalinn/parastell:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/svalinn/parastell:ci-layer-cache,mode=max
cache-from: type=registry,ref=ghcr.io/svalinn/parastell:ci-layer-cache${{ env.EXTRA_TAG }}
cache-to: type=registry,ref=ghcr.io/svalinn/parastell:ci-layer-cache${{ env.EXTRA_TAG }},mode=max
file: Dockerfile
push: true
target: parastell-deps
tags: ghcr.io/svalinn/parastell-ci
tags: ghcr.io/svalinn/parastell-ci${{ env.EXTRA_TAG_CI }}

test-dependency-img:
needs: build-dependency-img
runs-on: ubuntu-latest
container: ghcr.io/svalinn/parastell-ci
container: ghcr.io/svalinn/parastell-ci${{ needs.build-dependency-img.outputs.image_tag }}

name: Test CI Image
steps:
Expand Down

0 comments on commit 3224b20

Please sign in to comment.