Skip to content

Commit

Permalink
Fine-grained push condition for prod container
Browse files Browse the repository at this point in the history
  • Loading branch information
haoming29 committed Apr 9, 2024
1 parent ceddcf1 commit b1d2e45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build-prod-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ on:
workflow_dispatch:
workflow_call:
inputs:
from_workflow_call:
release_workflow:
required: false
type: boolean
default: true
default: false
tag:
description: 'Tag to use for the Docker image'
required: false
Expand All @@ -32,20 +32,20 @@ jobs:
# which is the branch for a feature version
- name: Set Branch for Release
id: set_branch
if: ${{ inputs.from_workflow_call }}
if: ${{ inputs.release_workflow }}
run: |
echo "branch=${GITHUB_REF_NAME%.*}.x" >> $GITHUB_OUTPUT
- name: Checkout for release with a tag
uses: actions/checkout@v4
if: ${{ inputs.from_workflow_call }}
if: ${{ inputs.release_workflow }}
with:
fetch-depth: 0
ref: ${{ steps.set_branch.outputs.branch }}

- name: Checkout for push to main
uses: actions/checkout@v4
if: ${{ !inputs.from_workflow_call }}
if: ${{ !inputs.release_workflow }}

- name: Cache base image
uses: actions/cache@v4
Expand Down Expand Up @@ -110,20 +110,20 @@ jobs:
# which is the branch for a feature version
- name: Set Branch for Release
id: set_branch
if: ${{ inputs.from_workflow_call }}
if: ${{ inputs.release_workflow }}
run: |
echo "branch=${GITHUB_REF_NAME%.*}.x" >> $GITHUB_OUTPUT
- name: Checkout for release with a tag
uses: actions/checkout@v4
if: ${{ inputs.from_workflow_call }}
if: ${{ inputs.release_workflow }}
with:
fetch-depth: 0
ref: ${{ steps.set_branch.outputs.branch }}

- name: Checkout for push to main
uses: actions/checkout@v4
if: ${{ !inputs.from_workflow_call }}
if: ${{ !inputs.release_workflow }}

- name: Generate tag list
id: generate-tag-list
Expand Down Expand Up @@ -183,7 +183,7 @@ jobs:
# if the workflow was for the release
- name: Log in to OSG Harbor
uses: docker/login-action@v3
if: github.repository == 'PelicanPlatform/pelican' && inputs.from_workflow_call
if: github.repository == 'PelicanPlatform/pelican' && inputs.release_workflow
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.PELICAN_HARBOR_ROBOT_USER }}
Expand All @@ -194,7 +194,7 @@ jobs:
with:
context: .
file: ./images/Dockerfile
push: ${{ github.repository == 'PelicanPlatform/pelican' && (inputs.from_workflow_call || false) }}
push: ${{ github.repository == 'PelicanPlatform/pelican' && (inputs.release_workflow || false) }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"
target: ${{ matrix.image }}
build-args: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ jobs:
secrets: inherit
with:
tag: ${{ needs.pre-release.outputs.tag }}
release_workflow: true

release:
needs: [pre-release]
Expand Down

0 comments on commit b1d2e45

Please sign in to comment.