Skip to content

Commit

Permalink
fix(CI): publish container images only when there is a release
Browse files Browse the repository at this point in the history
  • Loading branch information
iamvigneshwars committed Dec 5, 2024
1 parent e76d971 commit ef6c299
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 10 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/_dashboard_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Dashboard Container

on:
workflow_call:
inputs:
push_image:
required: true
type: boolean

jobs:
build_container:
Expand Down Expand Up @@ -47,8 +51,8 @@ jobs:
with:
context: ./frontend
target: nginx
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
push: ${{ inputs.push_image }}
load: ${{ inputs.push_image != 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/_graph_proxy_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Graph Proxy Container

on:
workflow_call:
inputs:
push_image:
required: true
type: boolean

jobs:
build:
Expand Down Expand Up @@ -42,8 +46,8 @@ jobs:
build-args: ARGO_SERVER_SCHEMA_URL=https://raw.githubusercontent.com/argoproj/argo-workflows/main/api/jsonschema/schema.json
context: ./graph-proxy
target: deploy
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
push: ${{ inputs.push_image }}
load: ${{ inputs.push_image != 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/_release_please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@ name: Release Please

on:
workflow_call:
outputs:
sessionspaces-released:
value: ${{ jobs.release-please.outputs.sessionspaces-released}}
graph-proxy-released:
value: ${{ jobs.release-please.outputs.graph-proxy-released}}
dashboard-released:
value: ${{ jobs.release-please.outputs.dashboard-released}}
secrets:
release_please_token:
required: true

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
sessionspaces-released: ${{ steps.release-please.outputs['sessionspaces--release_created'] }}
graph-proxy-released: ${{ steps.release-please.outputs['graph-proxy--release_created'] }}
dashboard-released: ${{ steps.release-please.outputs['dashboard--release_created'] }}
permissions:
contents: write
pull-requests: write
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/_sessionspaces_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Sessionspaces Container

on:
workflow_call:
inputs:
push_image:
required: true
type: boolean

jobs:
build:
Expand Down Expand Up @@ -55,8 +59,8 @@ jobs:
context: ./sessionspaces
build-args: DATABASE_URL=mysql://root:rootpassword@localhost:3306/ispyb_build
target: deploy
push: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
load: ${{ !(github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
push: ${{ inputs.push_image }}
load: ${{ inputs.push_image != 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand Down
45 changes: 41 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,23 @@ jobs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
uses: ./.github/workflows/_sessionspaces_code.yaml

sessionspaces_container:
sessionspaces_container_build:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs: sessionspaces_code
uses: ./.github/workflows/_sessionspaces_container.yaml
with:
push_image: false
permissions:
contents: read
packages: write

sessionspaces_container_publish:
needs: [sessionspaces_code, release_please]
if: needs.release_please.outputs.sessionspaces-released == 'true'
uses: ./.github/workflows/_sessionspaces_container.yaml
with:
push_image: true
permissions:
contents: read
packages: write
Expand All @@ -40,11 +52,24 @@ jobs:
needs: graph_proxy_code
uses: ./.github/workflows/_graph_proxy_schema.yaml

graph_proxy_container:
graph_proxy_container_build:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs: graph_proxy_code
uses: ./.github/workflows/_graph_proxy_container.yaml
with:
push_image: false
permissions:
contents: read
packages: write

graph_proxy_container_publish:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
needs: [graph_proxy_code, release_please]
if: needs.release_please.outputs.graph-proxy-released == 'true'
uses: ./.github/workflows/_graph_proxy_container.yaml
with:
push_image: true
permissions:
contents: read
packages: write
Expand All @@ -69,11 +94,23 @@ jobs:
needs: supergraph_composition
uses: ./.github/workflows/_frontend_code.yaml

dashboard_container:
dashboard_container_build:
# Deduplicate jobs from pull requests and branch pushes within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
needs: frontend_code
uses: ./.github/workflows/_dashboard_container.yaml
with:
push_image: false
permissions:
contents: read
packages: write

dashboard_container_publish:
needs: [frontend_code, release_please]
if: needs.release_please.outputs.dashboard-released == 'true'
uses: ./.github/workflows/_dashboard_container.yaml
with:
push_image: true
permissions:
contents: read
packages: write
Expand All @@ -96,7 +133,7 @@ jobs:
release_please:
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main')
uses: ./.github/workflows/_release_please.yaml
secrets:
secrets:
release_please_token: ${{ secrets.RELEASE_PLEASE_CLIENT_SECRET }}
permissions:
contents: write
Expand Down

0 comments on commit ef6c299

Please sign in to comment.