Skip to content

Commit

Permalink
Only push Docker images to Harbor on workflow_dispatch #133
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Nov 12, 2024
1 parent b923526 commit a470be7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: CI
on:
workflow_dispatch:
inputs:
push-docker-image-to-harbor:
description: 'Push Docker Image to Harbor'
type: boolean
default: false

pull_request:
push:
branches:
Expand Down Expand Up @@ -82,12 +88,11 @@ jobs:
run: nox -s safety

docker:
# This job triggers only if all the other jobs succeed and does different things depending on the context.
# The job builds the Docker image in all cases and also pushes the image to Harbor only if something is
# pushed to the main branch.
needs: [tests, linting, formatting, safety]
name: Docker
runs-on: ubuntu-20.04
env:
PUSH_DOCKER_IMAGE_TO_HARBOR: ${{ inputs.push-docker-image-to-harbor }}
steps:
- name: Check out repo
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.5.2
Expand All @@ -105,11 +110,11 @@ jobs:
with:
images: harbor.stfc.ac.uk/datagateway/scigateway-auth

- name: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'Build and push Docker image to Harbor' || 'Build Docker image' }}
- name: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) && 'Build and push Docker image to Harbor' || 'Build Docker image' }}
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
context: .
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
push: ${{ fromJSON(env.PUSH_DOCKER_IMAGE_TO_HARBOR) }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
target: prod

0 comments on commit a470be7

Please sign in to comment.