Skip to content

Commit 22c966f

Browse files
authored
Merge pull request #436 from mkurz/gha_if
Make sure workflows only run in `lightbend/ssl-config` repo
2 parents c0e16fb + a7171bf commit 22c966f

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ jobs:
7171
shell: bash
7272
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck
7373

74-
- shell: bash
74+
- if: github.repository == 'lightbend/ssl-config'
75+
shell: bash
7576
run: sbt '++ ${{ matrix.scala }}' validateCode test doc mimaReportBinaryIssues
7677

77-
- if: matrix.java != 'temurin@8'
78+
- if: matrix.java != 'temurin@8' && github.repository == 'lightbend/ssl-config'
7879
shell: bash
7980
run: ./scripts/validate-docs.sh
8081

@@ -91,7 +92,7 @@ jobs:
9192
publish:
9293
name: Publish Artifacts
9394
needs: [build]
94-
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
95+
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && (github.repository == 'lightbend/ssl-config')
9596
strategy:
9697
matrix:
9798
os: [ubuntu-latest]

build.sbt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import com.github.sbt.osgi.SbtOsgi
22
import com.github.sbt.osgi.SbtOsgi.autoImport._
33
import com.typesafe.tools.mima.core._
4+
import Common.autoImport._
45

56
ThisBuild / scalaVersion := Version.scala212
67
ThisBuild / crossScalaVersions := Seq(Version.scala213, Version.scala212, Version.scala3)
@@ -159,11 +160,18 @@ def versionedImport(packageName: String, lower: String, upper: String) = s"""$pa
159160
addCommandAlias("validateCode", "headerCheckAll ; scalafmtSbtCheck ; scalafmtCheckAll")
160161

161162
ThisBuild / githubWorkflowBuild := Seq(
162-
WorkflowStep.Sbt(List("validateCode", "test", "doc", "mimaReportBinaryIssues")),
163-
WorkflowStep.Run(List("./scripts/validate-docs.sh"), cond = Some("matrix.java != 'temurin@8'")),
163+
WorkflowStep.Sbt(
164+
List("validateCode", "test", "doc", "mimaReportBinaryIssues"),
165+
cond = Some(s"github.repository == '${githubOrg}/${githubRepo}'")
166+
),
167+
WorkflowStep.Run(
168+
List("./scripts/validate-docs.sh"),
169+
cond = Some(s"matrix.java != 'temurin@8' && github.repository == '${githubOrg}/${githubRepo}'")
170+
),
164171
)
165172

166173
ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
174+
ThisBuild / githubWorkflowPublishCond := Some(s"github.repository == '${githubOrg}/${githubRepo}'")
167175
ThisBuild / githubWorkflowPublishTargetBranches :=
168176
Seq(
169177
RefPredicate.StartsWith(Ref.Tag("v")),

project/Common.scala

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,28 @@ import sbtheader.HeaderPlugin
1818
*/
1919
object Common extends AutoPlugin {
2020

21+
object autoImport {
22+
val githubOrg = "lightbend"
23+
val githubRepo = "ssl-config"
24+
}
25+
26+
import autoImport._
27+
2128
override def trigger = allRequirements
2229

2330
override def requires = plugins.JvmPlugin && HeaderPlugin
2431

2532
// AutomateHeaderPlugin is not an allRequirements-AutoPlugin, so explicitly add settings here:
26-
override def projectSettings =
33+
override def projectSettings = {
2734
AutomateHeaderPlugin.projectSettings ++
2835
Seq(
2936
organization := "com.typesafe",
30-
homepage := Some(url("https://lightbend.github.io/ssl-config/")),
37+
homepage := Some(url(s"https://${githubOrg}.github.io/${githubRepo}/")),
3138
scmInfo := Some(
3239
ScmInfo(
33-
url(s"https://github.com/lightbend/ssl-config"),
34-
s"scm:git:https://github.com/lightbend/ssl-config.git",
35-
Some(s"scm:git:[email protected]:lightbend/ssl-config.git")
40+
url(s"https://github.com/${githubOrg}/${githubRepo}"),
41+
s"scm:git:https://github.com/${githubOrg}/${githubRepo}.git",
42+
Some(s"scm:git:[email protected]:${githubOrg}/${githubRepo}.git")
3643
)
3744
),
3845
developers := List(
@@ -63,5 +70,6 @@ object Common extends AutoPlugin {
6370
)
6471
}
6572
)
73+
}
6674

6775
}

0 commit comments

Comments
 (0)