Skip to content

Commit

Permalink
Fix defaults for inputs as ternary operator
Browse files Browse the repository at this point in the history
The GHA don't treat an empty input as fallback to default value,
therefore we need to use something like `ARTIFACTORY_REPOSITORY: ${{ inputs.targetRepository == '' && 'libs-snapshot-local' || inputs.targetRepository }}` instead.

* Fix milestone and central workflows to rely on the `secrets.JF_ARTIFACTORY_SPRING` instead of specific credentials
* Propagate defaults from one reusable workflow to another since the previously mentioned treating for empty input
  • Loading branch information
artembilan committed Feb 9, 2024
1 parent 8f248b2 commit cc6eaf1
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/actions/spring-artifactory-gradle-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ runs:
echo "::notice title=Artifactory Build Name & Number::$ARTIFACTORY_BUILD_NAME/$ARTIFACTORY_BUILD_NUMBER"
shell: bash
env:
ARTIFACTORY_URL: ${{ inputs.artifactoryUrl }}/artifactory
ARTIFACTORY_REPOSITORY: ${{ inputs.targetRepository }}
ARTIFACTORY_URL: ${{ inputs.artifactoryUrl == '' && 'https://repo.spring.io' || inputs.artifactoryUrl }}/artifactory
ARTIFACTORY_REPOSITORY: ${{ inputs.targetRepository == '' && 'libs-snapshot-local' || inputs.targetRepository }}
ARTIFACTORY_BUILD_PROJECT: ${{ inputs.artifactoryProjectKey }}
ARTIFACTORY_BUILD_NAME: ${{ steps.build-name.outputs.buildName }}
ARTIFACTORY_BUILD_NUMBER: ${{ github.run_number }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ on:
description: 'The Artifactory Server'
required: false
type: string
default: https://repo.spring.io
stagingRepository:
description: 'The Artifactory Repository to stage artifacts to'
required: false
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/spring-artifactory-gradle-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ on:
description: 'The Artifactory Repository to stage artifacts to'
required: false
type: string
default: libs-staging-local
targetMilestoneRepository:
description: 'The Artifactory Repository to promote the milestone build to'
required: false
type: string
default: libs-milestone-local
targetReleaseRepository:
description: 'The Artifactory Repository to promote the release build to'
required: false
type: string
default: libs-release-local
artifactoryProjectKey:
description: 'The Artifactory project key'
required: false
Expand Down Expand Up @@ -115,7 +118,6 @@ jobs:
if: ${{ !contains(needs.releaseVersion.outputs.releaseVersion, '-') }}
uses: ./.github/workflows/spring-artifactory-promote-central.yml
with:
artifactoryUrl: ${{ inputs.artifactoryUrl }}
buildName: ${{ needs.staging.outputs.buildName }}
buildNumber: ${{ needs.staging.outputs.buildNumber }}
targetRepository: ${{ inputs.targetReleaseRepository }}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/spring-artifactory-gradle-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ on:
description: 'The Artifactory Server'
required: false
type: string
default: https://repo.spring.io
targetRepository:
description: 'The Artifactory Repository to upload snapshot artifacts to'
required: false
type: string
default: libs-snapshot-local
artifactoryProjectKey:
description: 'The Artifactory project key'
required: false
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/spring-artifactory-promote-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ name: Promote Staged GA release from Artifactory to Maven Central
on:
workflow_call:
inputs:
artifactoryUrl:
description: 'The Artifactory Server'
required: false
type: string
default: https://repo.spring.io
artifactoryProjectKey:
description: 'The Artifactory project key'
required: false
Expand Down
9 changes: 0 additions & 9 deletions .github/workflows/spring-artifactory-promote-milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ name: Promote Staged Milestone in Artifactory
on:
workflow_call:
inputs:
artifactoryUrl:
description: 'The Artifactory Server'
required: false
type: string
default: https://repo.spring.io
artifactoryProjectKey:
description: 'The Artifactory project key'
required: false
Expand Down Expand Up @@ -40,10 +35,6 @@ jobs:
steps:

- uses: jfrog/setup-jfrog-cli@v4
env:
JF_URL: ${{ inputs.artifactoryUrl }}
JF_USER: ${{ secrets.ARTIFACTORY_USERNAME }}
JF_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Promote Build
run: jfrog rt build-promote ${{ inputs.buildName }} ${{ inputs.buildNumber }} ${{ inputs.targetRepository }} --project=${{ inputs.artifactoryProjectKey }}

0 comments on commit cc6eaf1

Please sign in to comment.