Actions(ephemeral-instances): Migrate to Vault (#104848)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
name: 'Ephemeral instances'
|
||||
name: "Ephemeral instances"
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
@@ -8,62 +9,46 @@ on:
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
config:
|
||||
runs-on: "ubuntu-latest"
|
||||
outputs:
|
||||
has-secrets: ${{ steps.check.outputs.has-secrets }}
|
||||
steps:
|
||||
- name: "Check for secrets"
|
||||
id: check
|
||||
shell: bash
|
||||
run: |
|
||||
if [ -n "${{ (secrets.EI_APP_ID != '' &&
|
||||
secrets.EI_APP_PRIVATE_KEY != '' &&
|
||||
secrets.EI_GCOM_HOST != '' &&
|
||||
secrets.EI_GCOM_TOKEN != '' &&
|
||||
secrets.EI_EPHEMERAL_INSTANCES_REGISTRY != '' &&
|
||||
secrets.EI_GCP_SERVICE_ACCOUNT_KEY_BASE64 != '' &&
|
||||
secrets.EI_EPHEMERAL_ORG_ID != ''
|
||||
) || '' }}" ]; then
|
||||
echo "has-secrets=1" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
handle-pull-request-event:
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
needs: config
|
||||
if: needs.config.outputs.has-secrets &&
|
||||
${{ github.event.issue.pull_request && (startsWith(github.event.comment.body, '/deploy-to-hg') || github.event.action == 'closed') }}
|
||||
handle-ephemeral-instances:
|
||||
if: ${{ github.event.issue.pull_request && (startsWith(github.event.comment.body, '/deploy-to-hg') || github.event.action == 'closed') && github.repository_owner == 'grafana' }}
|
||||
runs-on:
|
||||
labels: ubuntu-latest-8-cores
|
||||
continue-on-error: true
|
||||
permissions:
|
||||
# For commenting.
|
||||
pull-requests: write
|
||||
# No contents permission is needed because we will impersonate an app to create the PR instead.
|
||||
id-token: write # required for vault access
|
||||
|
||||
steps:
|
||||
- name: Get vault secrets
|
||||
id: vault-secrets
|
||||
uses: grafana/shared-workflows/actions/get-vault-secrets@main
|
||||
with:
|
||||
# Secrets placed in ci/repo/grafana/grafana/
|
||||
repo_secrets: |
|
||||
APP_ID=ephemeral-instances-bot:app-id
|
||||
APP_PEM=ephemeral-instances-bot:app-private-key
|
||||
GCOM_HOST=ephemeral-instances-bot:gcom-host
|
||||
GCOM_TOKEN=ephemeral-instances-bot:gcom-token
|
||||
REGISTRY=ephemeral-instances-bot:registry
|
||||
GCP_SA_ACCOUNT_KEY_BASE64=ephemeral-instances-bot:sa-key
|
||||
|
||||
- name: Generate a GitHub app installation token
|
||||
id: generate_token
|
||||
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
||||
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
|
||||
with:
|
||||
app_id: ${{ secrets.EI_APP_ID }}
|
||||
private_key: ${{ secrets.EI_APP_PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout ephemeral instances repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: grafana/ephemeral-grafana-instances-github-action
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
ref: main
|
||||
path: ephemeral
|
||||
persist-credentials: false
|
||||
app_id: ${{ env.APP_ID }}
|
||||
private_key: ${{ env.APP_PEM }}
|
||||
|
||||
- name: build and deploy ephemeral instance
|
||||
uses: ./ephemeral
|
||||
uses: grafana/ephemeral-grafana-instances-github-action@main
|
||||
with:
|
||||
github-token: ${{ steps.generate_token.outputs.token }}
|
||||
gcom-host: ${{ secrets.EI_GCOM_HOST }}
|
||||
gcom-token: ${{ secrets.EI_GCOM_TOKEN }}
|
||||
registry: "${{ secrets.EI_EPHEMERAL_INSTANCES_REGISTRY }}"
|
||||
gcp-service-account-key: "${{ secrets.EI_GCP_SERVICE_ACCOUNT_KEY_BASE64 }}"
|
||||
ephemeral-org-id: "${{ secrets.EI_EPHEMERAL_ORG_ID }}"
|
||||
github-token: ${{ steps.generate_token.outputs.token }}
|
||||
gcom-host: ${{ env.GCOM_HOST }}
|
||||
gcom-token: ${{ env.GCOM_TOKEN }}
|
||||
registry: "${{ env.REGISTRY }}"
|
||||
gcp-service-account-key: ${{ env.GCP_SA_ACCOUNT_KEY_BASE64 }}
|
||||
ephemeral-org-id: ephemeral
|
||||
oss-or-enterprise: oss
|
||||
verbose: true
|
||||
|
||||
Reference in New Issue
Block a user