Skip to content

Commit c1af344

Browse files
authored
Remove building from running time (#155)
Part of #4. Thanks to this, the users don't need to wait for the project to build with Gradle, which took around 1-2 minutes. Now it takes a few seconds to build the Docker image, and under 1 second to run the action itself.
1 parent fde861a commit c1af344

11 files changed

+58
-8
lines changed

.github/workflows/build.main.kts

+30
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@ workflow(
2525
) {
2626
uses(action = CheckoutV4())
2727
uses(action = GradleBuildActionV2(arguments = "build"))
28+
29+
run(
30+
name = "Check if the produced files are committed correctly",
31+
command = """
32+
set -euxo pipefail
33+
34+
unzip_jar() {
35+
for jar in dist/github-actions-typing/lib/*.jar; do
36+
echo "Extracting ${'$'}jar..."
37+
filename=${'$'}(basename -- "${'$'}jar")
38+
filename="${'$'}{filename%.*}"
39+
40+
targetDir="${'$'}1/${'$'}filename"
41+
echo "Target directory: ${'$'}targetDir"
42+
43+
mkdir -p "${'$'}targetDir"
44+
unzip -qq "${'$'}jar" -d "${'$'}targetDir"
45+
done
46+
}
47+
48+
unzip_jar "dist-unzipped-before"
49+
50+
rm -rf dist
51+
unzip -qq build/distributions/github-actions-typing.zip -d dist
52+
53+
unzip_jar "dist-unzipped-after"
54+
55+
git diff --no-index --exit-code dist-unzipped-before dist-unzipped-after
56+
""".trimIndent()
57+
)
2858
}
2959

3060
job(

.github/workflows/build.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,33 @@ jobs:
3333
uses: 'gradle/gradle-build-action@v2'
3434
with:
3535
arguments: 'build'
36+
- id: 'step-2'
37+
name: 'Check if the produced files are committed correctly'
38+
run: |-
39+
set -euxo pipefail
40+
41+
unzip_jar() {
42+
for jar in dist/github-actions-typing/lib/*.jar; do
43+
echo "Extracting $jar..."
44+
filename=$(basename -- "$jar")
45+
filename="${filename%.*}"
46+
47+
targetDir="$1/$filename"
48+
echo "Target directory: $targetDir"
49+
50+
mkdir -p "$targetDir"
51+
unzip -qq "$jar" -d "$targetDir"
52+
done
53+
}
54+
55+
unzip_jar "dist-unzipped-before"
56+
57+
rm -rf dist
58+
unzip -qq build/distributions/github-actions-typing.zip -d dist
59+
60+
unzip_jar "dist-unzipped-after"
61+
62+
git diff --no-index --exit-code dist-unzipped-before dist-unzipped-after
3663
validate-types:
3764
runs-on: 'ubuntu-latest'
3865
needs:

Dockerfile

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
1-
FROM gradle:8.4.0-jdk17 AS build
2-
COPY --chown=gradle:gradle . /src
3-
WORKDIR /src
4-
RUN gradle build --no-daemon
5-
RUN rm -rf dist
6-
RUN unzip build/distributions/github-actions-typing.zip -d dist
7-
81
FROM eclipse-temurin:21.0.1_12-jre
92
RUN mkdir /app
10-
COPY --from=build /src/dist/github-actions-typing/lib/*.jar /app/
3+
COPY dist/github-actions-typing/lib/*.jar /app/
114
WORKDIR /app
125

136
ENTRYPOINT ["java", "-cp", "/app/*", "it.krzeminski.githubactionstyping.MainKt"]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)