-
Notifications
You must be signed in to change notification settings - Fork 19
chore: Use GH app instead of PAT #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
22c1b9c
cebfbc8
f033ee2
b5fd6b5
9f9cc81
3bdae8f
c174000
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: "Dependabot Auto-Merge" | ||
| name: 'Dependabot Auto-Merge' | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
|
|
@@ -14,29 +14,38 @@ env: | |
| jobs: | ||
| review-prs: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: write | ||
| contents: write | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Contents write should not be needed, because we only approve and merge the pr. Please make sure that is correct. |
||
| steps: | ||
| - name: Generate GitHub App token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@v3 | ||
| with: | ||
| app-id: ${{ secrets.SAP_AI_SDK_BOT_CLIENT_ID }} | ||
| private-key: ${{ secrets.SAP_AI_SDK_BOT_PRIVATE_KEY }} | ||
| owner: SAP | ||
| repositories: ai-sdk-java | ||
| permission-pull-requests: write | ||
|
|
||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Approve and Merge PRs | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| PRS=$(gh pr list --app "dependabot" --state "open" --json number,title) | ||
| PR_NUMBERS= | ||
| while IFS= read -r GROUP; do | ||
| if [[ -z "$GROUP" ]]; then | ||
| continue | ||
| fi | ||
|
|
||
| MATCHES=$(jq -r --arg group "$GROUP" '.[] | select(.title | contains($group)) | .number' <<< "$PRS") | ||
| echo "[DEBUG] Found PRs for group '$GROUP': '$MATCHES'" | ||
|
|
||
| PR_NUMBERS="$MATCHES"$'\n'"$PR_NUMBERS" | ||
| done <<< "${{ env.DEPENDABOT_GROUPS }}" | ||
| echo "[DEBUG] Approving and Merging following PRs: '$PR_NUMBERS'" | ||
|
|
||
| while IFS= read -r PR_NUMBER; do | ||
| if [[ -z "$PR_NUMBER" ]]; then | ||
| continue | ||
|
|
@@ -46,5 +55,3 @@ jobs: | |
| gh pr merge "$PR_NUMBER" --auto --squash | ||
| gh pr review "$PR_NUMBER" --approve | ||
| done <<< "$PR_NUMBERS" | ||
| env: | ||
| GH_TOKEN: ${{ secrets.BOT_SDK_JS_FOR_DOCS_REPO_PR }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| name: "Fosstars (Security)" | ||
| name: 'Fosstars (Security)' | ||
| on: | ||
| workflow_dispatch: | ||
| schedule: | ||
|
|
@@ -13,53 +13,53 @@ env: | |
|
|
||
| jobs: | ||
| create_fosstars_report: | ||
| name: "Security rating" | ||
| name: 'Security rating' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| contents: write | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently the 'Fosstars Rating' writes to the current branch, which shouldn't work without this permission. Please check if this is correct and otherwise revert to |
||
| actions: write | ||
| steps: | ||
| - name: "Checkout repository" | ||
| - name: 'Checkout repository' | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: "Setup java" | ||
| - name: 'Setup java' | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: "sapmachine" | ||
| distribution: 'sapmachine' | ||
| java-version: ${{ env.JAVA_VERSION }} | ||
| cache: 'maven' | ||
|
|
||
| - name: "Restore CVE Database" | ||
| - name: 'Restore CVE Database' | ||
| uses: actions/cache/restore@v5 | ||
| with: | ||
| path: ${{ env.CVE_CACHE_DIR }} | ||
| key: ${{ env.CVE_CACHE_KEY }} | ||
| # fail-on-cache-miss: true | ||
| # fail-on-cache-miss: true | ||
|
|
||
| - name: "Build SDK" | ||
| - name: 'Build SDK' | ||
| run: | | ||
| MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} clean install -DskipTests -DskipFormatting" | ||
| mvn $MVN_ARGS | ||
|
|
||
| - name: "Create settings.xml" | ||
| - name: 'Create settings.xml' | ||
| run: | | ||
| echo '${{ secrets.OSS_INDEX_SETTINGS_XML }}' > settings.xml | ||
|
|
||
| - name: "CVE Scan" | ||
| - name: 'CVE Scan' | ||
| env: | ||
| NVD_API_KEY: ${{ secrets.NVD_API_KEY }} | ||
| run: > | ||
| mvn -T1 --no-transfer-progress -s settings.xml | ||
| --batch-mode org.owasp:dependency-check-maven:check org.owasp:dependency-check-maven:aggregate | ||
|
|
||
| - name: "Archive CVE Report" | ||
| - name: 'Archive CVE Report' | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: cve-report | ||
| path: target/dependency-check-report.html | ||
| retention-days: 7 | ||
|
|
||
| - name: "Delete Old CVE Cache" | ||
| - name: 'Delete Old CVE Cache' | ||
| run: | | ||
| CACHE_IDS=$(gh cache list --key "${{ env.CVE_CACHE_KEY }}" --ref "${{ env.CVE_CACHE_REF }}" --json id | jq -r '.[] | .id') | ||
| for CACHE_ID in $CACHE_IDS; do | ||
|
|
@@ -69,20 +69,20 @@ jobs: | |
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: "Create Updated CVE Cache" | ||
| - name: 'Create Updated CVE Cache' | ||
| uses: actions/cache/save@v5 | ||
| with: | ||
| path: ${{ env.CVE_CACHE_DIR }} | ||
| key: ${{ env.CVE_CACHE_KEY }} | ||
|
|
||
| # This action changes the active branch! | ||
| - name: "Fosstars Rating" | ||
| - name: 'Fosstars Rating' | ||
| uses: SAP/fosstars-rating-core-action@v1.14.0 | ||
| with: | ||
| report-branch: fosstars-report | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: "Slack Notification" | ||
| - name: 'Slack Notification' | ||
| if: failure() | ||
| uses: slackapi/slack-github-action@v2.1.1 | ||
| with: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this doesn't trigger any follow up workflows? Then
GITHUB_TOKENshould be enough.