|
30 | 30 | github_app_pem:
|
31 | 31 | description: GitHub APP pem to authenticate with
|
32 | 32 | required: false
|
| 33 | + vault_repo_secret_name: |
| 34 | + description: Vault secret name that holds repository's GitHub App credentials to authenticate with |
| 35 | + required: false |
33 | 36 | helm_repo_token:
|
34 | 37 | description: GitHub api token to use against the helm-charts repository
|
35 | 38 | required: false
|
@@ -96,26 +99,41 @@ jobs:
|
96 | 99 | needs: [setup]
|
97 | 100 | runs-on: ubuntu-latest
|
98 | 101 | permissions:
|
| 102 | + id-token: write # allows GitHub App to generate id-token from Github's OIDC |
99 | 103 | contents: write # allows GITHUB_TOKEN to push chart release, create release, and push tags to github
|
100 | 104 | packages: write # allows GITHUB_TOKEN to push package to ghcr
|
101 | 105 | env:
|
102 |
| - github_app_id: ${{ secrets.github_app_id }} |
| 106 | + # APP_ID and PRIVATE_KEY are overwritten by credentials from vault, if configured |
| 107 | + GITHUB_APP_ID: ${{ secrets.github_app_id }} |
| 108 | + PRIVATE_KEY: ${{ secrets.github_app_pem }} |
| 109 | + VAULT_REPO_SECRET_NAME: ${{ secrets.vault_repo_secret_name }} |
103 | 110 | if: needs.setup.outputs.changed == 'true'
|
104 | 111 | steps:
|
105 |
| - - name: Create a GitHub App installation access token |
106 |
| - if: env.github_app_id != '' |
107 |
| - uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0 |
| 112 | + - name: Retrieve GitHub App credentials from Vault |
| 113 | + if: env.VAULT_REPO_SECRET_NAME != '' |
| 114 | + id: get-secrets |
| 115 | + uses: grafana/shared-workflows/actions/get-vault-secrets@28361cdb22223e5f1e34358c86c20908e7248760 # v1.1.0 |
| 116 | + with: |
| 117 | + repo_secrets: | |
| 118 | + GITHUB_APP_ID=${{ env.VAULT_REPO_SECRET_NAME }}:app-id |
| 119 | + PRIVATE_KEY=${{ env.VAULT_REPO_SECRET_NAME }}:private-key |
| 120 | +
|
| 121 | + - name: Generate GitHub App Token |
| 122 | + if: env.GITHUB_APP_ID != '' |
108 | 123 | id: app-token
|
| 124 | + uses: actions/create-github-app-token@v1 |
109 | 125 | with:
|
110 |
| - app_id: ${{ env.github_app_id }} |
111 |
| - private_key: ${{ secrets.github_app_pem }} |
| 126 | + # Variables generated by the previous step get-secrets |
| 127 | + app-id: ${{ env.GITHUB_APP_ID }} |
| 128 | + private-key: ${{ env.PRIVATE_KEY }} |
| 129 | + owner: ${{ github.repository_owner }} |
112 | 130 |
|
113 | 131 | - name: Set the correct token (Github App or PAT)
|
114 | 132 | env:
|
115 | 133 | HELM_REPO_TOKEN: ${{ secrets.helm_repo_token }}
|
116 | 134 | APP_TOKEN: ${{ steps.app-token.outputs.token }}
|
117 | 135 | run: |
|
118 |
| - if [[ "${github_app_id}" == '' ]]; then |
| 136 | + if [[ "${GITHUB_APP_ID}" == '' ]]; then |
119 | 137 | echo "AUTHTOKEN=${HELM_REPO_TOKEN}" >> $GITHUB_ENV
|
120 | 138 | else
|
121 | 139 | echo "AUTHTOKEN=${APP_TOKEN}" >> $GITHUB_ENV
|
|
0 commit comments