Skip to content

Commit fd932ae

Browse files
committed
github actions refactor
1 parent cc8b6f9 commit fd932ae

File tree

4 files changed

+23
-122
lines changed

4 files changed

+23
-122
lines changed

.github/workflows/ci.yml

+14-91
Original file line numberDiff line numberDiff line change
@@ -6,111 +6,34 @@ on:
66
branches: ['**']
77
tags: [v*]
88
jobs:
9-
ci:
9+
build:
10+
uses: softwaremill/github-actions-workflows/.github/workflows/build-scala.yml@main
1011
# run on 1) push, 2) external PRs, 3) softwaremill-ci PRs
1112
# do not run on internal, non-steward PRs since those will be run by push to branch
1213
if: |
1314
github.event_name == 'push' ||
1415
github.event.pull_request.head.repo.full_name != github.repository ||
1516
github.event.pull_request.user.login == 'softwaremill-ci'
16-
runs-on: ubuntu-22.04
17-
steps:
18-
- name: Checkout
19-
uses: actions/checkout@v4
20-
- name: Set up JDK
21-
uses: actions/setup-java@v4
22-
with:
23-
distribution: 'zulu'
24-
java-version: '21'
25-
cache: 'sbt'
26-
- name: Compile
27-
run: sbt -v compile
28-
- name: Compile documentation
29-
run: sbt -v compileDocs
30-
- name: Test
31-
run: sbt -v test
32-
- uses: actions/upload-artifact@v4 # upload test results
33-
if: success() || failure() # run this step even if previous step failed
34-
with:
35-
name: 'tests-results'
36-
path: '**/test-reports/TEST*.xml'
17+
with:
18+
java-version: '21'
19+
compile-documentation: true
3720

3821
publish:
39-
name: Publish release
40-
needs: [ci]
22+
uses: softwaremill/github-actions-workflows/.github/workflows/publish-release.yml@main
23+
needs: [build]
4124
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v'))
42-
runs-on: ubuntu-22.04
43-
env:
44-
JAVA_OPTS: -Xmx4G
45-
steps:
46-
- name: Checkout
47-
uses: actions/checkout@v4
48-
- name: Set up JDK
49-
uses: actions/setup-java@v4
50-
with:
51-
distribution: 'zulu'
52-
java-version: '21'
53-
cache: 'sbt'
54-
- name: Compile
55-
run: sbt compile
56-
- name: Publish artifacts
57-
run: sbt ci-release
58-
env:
59-
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
60-
PGP_SECRET: ${{ secrets.PGP_SECRET }}
61-
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
62-
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
63-
- name: Extract version from commit message
64-
run: |
65-
version=${GITHUB_REF/refs\/tags\/v/}
66-
echo "VERSION=$version" >> $GITHUB_ENV
67-
env:
68-
COMMIT_MSG: ${{ github.event.head_commit.message }}
69-
- name: Publish release notes
70-
uses: release-drafter/release-drafter@v5
71-
with:
72-
config-name: release-drafter.yml
73-
publish: true
74-
name: "v${{ env.VERSION }}"
75-
tag: "v${{ env.VERSION }}"
76-
version: "v${{ env.VERSION }}"
77-
env:
78-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
secrets: inherit
26+
with:
27+
java-version: '21'
28+
java-opts: "-Xmx4G"
7929

80-
# `automerge` label is attached iff there is exactly one file changed by steward and this file belongs to a
81-
# whitelist specified by `labeler.yml`
8230
label:
83-
name: Attach automerge label
8431
# only for PRs by softwaremill-ci
8532
if: github.event.pull_request.user.login == 'softwaremill-ci'
86-
runs-on: ubuntu-22.04
87-
steps:
88-
- uses: actions/checkout@v4
89-
with:
90-
fetch-depth: 2
91-
# count number of files changed
92-
- name: Count number of files changed
93-
id: count-changed-files
94-
run: |
95-
N=$(git diff --name-only -r HEAD^1 HEAD | wc -w)
96-
echo "changed_files_num=$N" >> $GITHUB_OUTPUT
97-
- name: Launch labeler
98-
# skip if more than one file changed
99-
if: steps.count-changed-files.outputs.changed_files_num == 1
100-
uses: srvaroa/labeler@master
101-
env:
102-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
33+
uses: softwaremill/github-actions-workflows/.github/workflows/label.yml@main
10334

10435
auto-merge:
105-
name: Auto merge
10636
# only for PRs by softwaremill-ci
10737
if: github.event.pull_request.user.login == 'softwaremill-ci'
108-
needs: [ ci, label ]
109-
runs-on: ubuntu-22.04
110-
steps:
111-
- id: automerge
112-
name: automerge
113-
uses: "pascalgn/automerge-action@v0.15.6"
114-
env:
115-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
116-
MERGE_METHOD: "squash"
38+
needs: [ build, label ]
39+
uses: softwaremill/github-actions-workflows/.github/workflows/auto-merge.yml@main

.github/workflows/scala-steward.yml

+5-18
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,8 @@ on:
88

99
jobs:
1010
scala-steward:
11-
runs-on: ubuntu-22.04
12-
steps:
13-
- name: Checkout
14-
uses: actions/checkout@v4
15-
- name: Set up JDK
16-
uses: actions/setup-java@v4
17-
with:
18-
distribution: 'zulu'
19-
java-version: '21'
20-
cache: 'sbt'
21-
- name: Launch Scala Steward
22-
uses: scala-steward-org/scala-steward-action@v2
23-
with:
24-
author-name: scala-steward
25-
author-email: scala-steward
26-
github-token: ${{ secrets.REPO_GITHUB_TOKEN }}
27-
repo-config: .scala-steward.conf
28-
ignore-opts-files: false
11+
uses: softwaremill/github-actions-workflows/.github/workflows/scala-steward.yml@main
12+
with:
13+
java-version: '21'
14+
secrets:
15+
repo-github-token: ${{secrets.REPO_GITHUB_TOKEN}}

.github/workflows/test-report.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,5 @@ permissions:
1111
checks: write
1212

1313
jobs:
14-
report:
15-
runs-on: ubuntu-22.04
16-
# If the workflow run was skipped or cancelled this action would fail, generating a test report is unnecessary.
17-
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure' }}
18-
steps:
19-
- uses: dorny/test-reporter@v1
20-
with:
21-
artifact: '/tests-results(.*)/'
22-
name: 'Test report for $1'
23-
path: '**/test-reports/TEST*.xml'
24-
reporter: java-junit
14+
test-report:
15+
uses: softwaremill/github-actions-workflows/.github/workflows/test-report.yml@main

build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ lazy val examples = (projectMatrix in file("examples"))
103103
)
104104
.dependsOn(ox)
105105

106-
val compileDocs: TaskKey[Unit] = taskKey[Unit]("Compiles docs module throwing away its output")
107-
compileDocs := {
106+
val compileDocumentation: TaskKey[Unit] = taskKey[Unit]("Compiles docs module throwing away its output")
107+
compileDocumentation := {
108108
(docs.jvm(scala2.head) / mdoc).toTask(" --out target/sttp-openai-docs").value
109109
}
110110

0 commit comments

Comments
 (0)