Skip to content
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

SDPLAT-26671: use GH_APP for GitHub REST API #161

Merged
merged 11 commits into from
Feb 4, 2025
40 changes: 39 additions & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: CodeQL
on:
pull_request:
schedule:
- cron: '09 09 * * 1'
- cron: "09 09 * * 1"

jobs:
codeql:
Expand All @@ -16,13 +16,51 @@ jobs:
with:
go-version: ^1.23

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
rnorth marked this conversation as resolved.
Show resolved Hide resolved

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
token: ${{ steps.app-token.outputs.token }}

- name: Build
run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
token: ${{ steps.app-token.outputs.token }}
upload: never

# Workaround for parallel GitHub bugs
# * Can't use GHA token with IP allowlisting
# https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#using-github-actions-with-an-ip-allow-list
# * Can't use codeql-action/analyze with custom token
# https://support.github.com/ticket/enterprise/3427/3214517
- name: Prepare CodeQL Results
run: |
gzip -c ../results/go.sarif | base64 -w0 > ./codeql-results.sarif.gz.b64

- uses: actions/upload-artifact@v4
with:
name: codeql
path: codeql-results.sarif.gz.b64

# Workaround for parallel GitHub bugs
# * Can't use GHA token with IP allowlisting
# https://docs.github.com/en/enterprise-cloud@latest/organizations/keeping-your-organization-secure/managing-security-settings-for-your-organization/managing-allowed-ip-addresses-for-your-organization#using-github-actions-with-an-ip-allow-list
# * Can't use codeql-action/analyze with custom token
# https://support.github.com/ticket/enterprise/3427/3214517
- name: Upload CodeQL Results
run: |
curl --fail-with-body \
-X POST \
-H "Authorization: token ${{ steps.app-token.outputs.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"commit_sha": "${{ github.sha }}", "ref": "${{ github.ref }}", "sarif": "$(cat ./codeql-results.sarif.gz.b64)"}' \
https://api.github.com/repos/${{ github.repository }}/code-scanning/sarifs
8 changes: 7 additions & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ jobs:
with:
go-version: ^1.23

- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
Loading