Skip to content

Commit 69dae87

Browse files
committed
Fix GitHub Actions workflow: secrets context not allowed in if conditions
Move secrets to job-level env vars and use env context in the conditional expression to check whether Sonatype credentials are available before publishing snapshot artifacts.
1 parent 75484c5 commit 69dae87

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ jobs:
1212

1313
runs-on: ubuntu-latest
1414

15+
env:
16+
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
17+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
18+
1519
steps:
1620
- uses: actions/checkout@v4
1721

@@ -27,7 +31,7 @@ jobs:
2731
arguments: build jacocoTestReport jacocoTestCoverageVerification
2832

2933
- name: Publish SNAPSHOT artifacts
30-
if: github.event_name == 'pull_request' && secrets.MAVEN_USERNAME != '' && secrets.MAVEN_PASSWORD != ''
34+
if: github.event_name == 'pull_request' && env.MAVEN_USERNAME != ''
3135
uses: gradle/gradle-build-action@v2.4.2
3236
with:
3337
arguments: publishToSonatype -PmavenRepoUsername=${{ secrets.MAVEN_USERNAME }} -PmavenRepoPassword=${{ secrets.MAVEN_PASSWORD }}

0 commit comments

Comments
 (0)