Skip to content

Commit a81384f

Browse files
committed
#369 Test GitHub action
1 parent f658832 commit a81384f

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/gradle-build.yml

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,58 @@ jobs:
1818
secrets:
1919
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
2020

21+
test-gh-action:
22+
needs: build-artifacts
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Check out
27+
uses: actions/checkout@v5
28+
29+
- name: Prepare Docker image for test
30+
run: |
31+
tag=$(git branch --show-current | tr '/' '-')
32+
docker pull ghcr.io/aim42/hsc:${tag}
33+
docker tag ghcr.io/aim42/hsc:${tag} ghcr.io/aim42/hsc:v2
34+
35+
- name: Download Artifacts
36+
uses: actions/download-artifact@v5
37+
with:
38+
name: build-artifacts
39+
path: .
40+
41+
- name: Run GH Action as provided by this repository
42+
uses: ./
43+
with:
44+
args: -r build/gh-action-test-report integration-test/common/build/docs --exclude 'https://www\.baeldung\.com/.*' --fail-on-errors
45+
46+
- name: Upload GH Action test results
47+
uses: actions/upload-artifact@v4
48+
with:
49+
path: build/gh-action-test-report
50+
51+
- name: Test Result of GH Action
52+
run: |
53+
if test -s build/gh-action-test-report/index.html; then
54+
echo "Test Successful"
55+
else
56+
echo "Test Failed: Report not found" >&2
57+
exit 1
58+
fi
59+
60+
- name: Collect state upon failure
61+
if: failure()
62+
run: |
63+
echo "Git:"
64+
git status
65+
echo "Env:"
66+
env | sort
67+
echo "PWD:"
68+
pwd
69+
echo "Files:"
70+
find * -ls
71+
./gradlew javaToolchains
72+
2173
post-build:
2274
needs: build-artifacts
2375
runs-on: ubuntu-latest
@@ -60,7 +112,7 @@ jobs:
60112
./gradlew javaToolchains
61113
62114
publish-docker-images:
63-
needs: build-artifacts
115+
needs: test-gh-action
64116
permissions:
65117
packages: write
66118
contents: read

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inputs:
88
required: false
99
runs:
1010
using: 'docker'
11+
# If the image tag changes, e.g., to v3, the action in the test workflow (workflows/gradle-build.yml) must be adjusted accordingly
1112
image: 'docker://ghcr.io/aim42/hsc:v2'
1213
entrypoint: '/bin/sh'
1314
args:

0 commit comments

Comments
 (0)