Skip to content

Commit c14c593

Browse files
committed
Harden SimpleAPI GitHub workflows
1 parent 3e5ddc2 commit c14c593

2 files changed

Lines changed: 62 additions & 22 deletions

File tree

‎.github/workflows/maven.yml‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ on:
1010
branches: [ "main" ]
1111

1212
permissions:
13-
contents: write # required for dependency submission
13+
contents: read
1414

1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2020

2121
- name: Set up JDK 21
22-
uses: actions/setup-java@v4
22+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
2323
with:
2424
java-version: '21'
2525
distribution: 'temurin'
@@ -28,10 +28,16 @@ jobs:
2828
- name: Build with Maven
2929
run: mvn -B -f SimpleAPI/pom.xml package
3030

31-
# Only run dependency graph submission on push (not pull_request)
31+
# Dependency submission needs write access, so keep it out of the build job.
32+
submit-dependency-snapshot:
33+
if: github.event_name == 'push'
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: write
37+
steps:
38+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
39+
3240
- name: Submit Dependency Snapshot
33-
if: github.event_name == 'push'
34-
uses: advanced-security/maven-dependency-submission-action@v5
41+
uses: advanced-security/maven-dependency-submission-action@b275d12641ac2d2108b2cbb7598b154ad2f2cee8 # v5.0.0
3542
with:
36-
directory: SimpleAPI # path to pom.xml
37-
# optional: maven-args: "-DskipTests"
43+
directory: SimpleAPI

‎.github/workflows/publish-javadoc.yml‎

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,56 @@ name: Deploy Javadoc
33
on:
44
release:
55
types: [published]
6-
branches:
7-
- master
8-
- main
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: github-pages
12+
cancel-in-progress: false
913

1014
jobs:
11-
publish:
15+
build:
16+
if: >-
17+
github.event.release.target_commitish == 'main' &&
18+
!github.event.release.prerelease
1219
runs-on: ubuntu-latest
20+
permissions:
21+
contents: read
1322
steps:
14-
- name: Deploy JavaDoc 🚀
15-
uses: MathieuSoysal/Javadoc-publisher.yml@main
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
ref: ${{ github.event.release.tag_name }}
26+
persist-credentials: false
27+
28+
- name: Set up JDK 21
29+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
30+
with:
31+
java-version: '21'
32+
distribution: temurin
33+
cache: maven
34+
35+
- name: Build Javadoc
36+
run: mvn -B -f SimpleAPI/pom.xml clean package -P javadoc javadoc:aggregate
37+
38+
- name: Upload Pages artifact
39+
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
1640
with:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18-
javadoc-branch: gh-pages
19-
java-version: 21
20-
target-folder: ''
21-
project: maven # or gradle
22-
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
23-
custom-command: mvn -f SimpleAPI/pom.xml deploy -P javadoc javadoc:aggregate
24-
javadoc-source-folder: 'SimpleAPI/target/reports/apidocs'
41+
path: SimpleAPI/target/reports/apidocs
42+
43+
deploy:
44+
needs: build
45+
if: >-
46+
github.event.release.target_commitish == 'main' &&
47+
!github.event.release.prerelease
48+
runs-on: ubuntu-latest
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
permissions:
53+
pages: write
54+
id-token: write
55+
steps:
56+
- name: Deploy to GitHub Pages
57+
id: deployment
58+
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5

0 commit comments

Comments
 (0)