Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/argocd-promote-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,22 @@ jobs:
core.info('Resolved configuration:');
core.info(JSON.stringify({ ...outputs, ...envVars }, null, 2));

- name: Validate GitHub App repository scope
if: inputs.auth_mode == 'app'
id: token-scope
shell: bash
env:
ENVIRONMENT_REPOSITORY: ${{ inputs.environment_repository }}
run: |
set -euo pipefail
shopt -s nocasematch
if [[ ! "$ENVIRONMENT_REPOSITORY" =~ ^([A-Za-z0-9-]+)/([A-Za-z0-9_.-]+)$ ||
"${BASH_REMATCH[1]}" != "${GITHUB_REPOSITORY_OWNER}" ]]; then
echo "::error::The environment repository must be owner/repo in the caller's organization"
exit 1
fi
printf 'repository=%s\n' "${BASH_REMATCH[2]}" >> "$GITHUB_OUTPUT"

- name: Generate GitHub App Token
if: inputs.auth_mode == 'app'
id: generate-token
Expand All @@ -311,6 +327,7 @@ jobs:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ steps.token-scope.outputs.repository }}

- name: Resolve Auth Token
id: auth
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/preview-cleanup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@ jobs:
contents: write

steps:
- name: Validate GitHub App repository scope
if: inputs.auth_mode == 'app'
id: token-scope
shell: bash
env:
ENVIRONMENT_REPOSITORY: ${{ inputs.environment_repository }}
run: |
set -euo pipefail
shopt -s nocasematch
if [[ ! "$ENVIRONMENT_REPOSITORY" =~ ^([A-Za-z0-9-]+)/([A-Za-z0-9_.-]+)$ ||
"${BASH_REMATCH[1]}" != "${GITHUB_REPOSITORY_OWNER}" ]]; then
echo "::error::The environment repository must be owner/repo in the caller's organization"
exit 1
fi
printf 'repository=%s\n' "${BASH_REMATCH[2]}" >> "$GITHUB_OUTPUT"

- name: Generate GitHub App Token
if: inputs.auth_mode == 'app'
id: generate-token
Expand All @@ -53,6 +69,7 @@ jobs:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_KEY }}
owner: ${{ github.repository_owner }}
repositories: ${{ steps.token-scope.outputs.repository }}

- name: Resolve Auth Token
id: auth
Expand Down
Loading