mirror of
https://github.com/grafana/grafana.git
synced 2025-08-06 20:59:35 +08:00
ci: add ephemeral instances action (#71604)
* ci: add ephemeral instances action * add operator experience squad to CODEOWNERS * only run action steps for a specific user
This commit is contained in:
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -629,6 +629,7 @@ embed.go @grafana/grafana-as-code
|
|||||||
/.github/workflows/publish-kinds-release.yml @grafana/grafana-as-code
|
/.github/workflows/publish-kinds-release.yml @grafana/grafana-as-code
|
||||||
/.github/workflows/verify-kinds.yml @grafana/grafana-as-code
|
/.github/workflows/verify-kinds.yml @grafana/grafana-as-code
|
||||||
/.github/workflows/dashboards-issue-add-label.yml @grafana/dashboards-squad
|
/.github/workflows/dashboards-issue-add-label.yml @grafana/dashboards-squad
|
||||||
|
/.github/workflows/ephemeral-instances.yml @grafana/grafana-operator-experience-squad
|
||||||
|
|
||||||
|
|
||||||
# Generated files not requiring owner approval
|
# Generated files not requiring owner approval
|
||||||
|
81
.github/workflows/ephemeral-instances.yml
vendored
Normal file
81
.github/workflows/ephemeral-instances.yml
vendored
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
name: 'Ephemeral instances action'
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
pull_request:
|
||||||
|
types: [opened, reopened, closed]
|
||||||
|
jobs:
|
||||||
|
handle-pull-request-event:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- name: Get pull request repo
|
||||||
|
if: github.triggering_actor == 'PoorlyDefinedBehaviour'
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
id: get-pull-request-repo
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: |
|
||||||
|
if(context.payload.pull_request?.head.ref) {
|
||||||
|
return context.payload.pull_request.head.ref
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await github.rest.pulls.get({
|
||||||
|
owner: "grafana",
|
||||||
|
repo: "grafana",
|
||||||
|
pull_number: context.payload.issue.number,
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data.head.ref
|
||||||
|
|
||||||
|
- name: Checkout Grafana
|
||||||
|
if: github.triggering_actor == 'PoorlyDefinedBehaviour'
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: grafana/grafana
|
||||||
|
ref: ${{ steps.get-pull-request-repo.outputs.result }}
|
||||||
|
path: grafana
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
if: github.triggering_actor == 'PoorlyDefinedBehaviour'
|
||||||
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: '>=1.20'
|
||||||
|
|
||||||
|
- name: Generate a GitHub app installation token
|
||||||
|
if: github.triggering_actor == 'PoorlyDefinedBehaviour'
|
||||||
|
id: generate_token
|
||||||
|
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.EI_APP_ID }}
|
||||||
|
private_key: ${{ secrets.EI_APP_PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Checkout ephemeral instances repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
repository: grafana/ephemeral-grafana-instances-github-action
|
||||||
|
token: ${{ steps.generate_token.outputs.token }}
|
||||||
|
ref: main
|
||||||
|
path: ephemeral
|
||||||
|
|
||||||
|
- name: Run action
|
||||||
|
if: github.triggering_actor == 'PoorlyDefinedBehaviour'
|
||||||
|
env:
|
||||||
|
GITHUB_EVENT: ${{ toJson(github.event)}}
|
||||||
|
run: |
|
||||||
|
GRAFANA_VERSION=10.1.0
|
||||||
|
|
||||||
|
cd $GITHUB_WORKSPACE/ephemeral/src
|
||||||
|
go run . \
|
||||||
|
-GITHUB_TOKEN="${{ steps.generate_token.outputs.token }}" \
|
||||||
|
-GITHUB_EVENT="$GITHUB_EVENT" \
|
||||||
|
-GITHUB_TRIGGERING_ACTOR="${{ github.triggering_actor }}" \
|
||||||
|
-GCOM_HOST="${{ secrets.EI_GCOM_HOST }}" \
|
||||||
|
-GCOM_TOKEN="${{ secrets.EI_GCOM_TOKEN }}" \
|
||||||
|
-HOSTED_GRAFANA_IMAGE_TAG="$GRAFANA_VERSION-ephemeral-grafana-${{ github.triggering_actor }}-${{ github.run_number }}-${{ github.run_attempt }}" \
|
||||||
|
-REGISTRY="${{ secrets.EI_EPHEMERAL_INSTANCES_REGISTRY }}" \
|
||||||
|
-GRAFANA_DIR="$GITHUB_WORKSPACE/grafana" \
|
||||||
|
-ENTERPRISE_REF="main" \
|
||||||
|
-GRAFANA_VERSION="$GRAFANA_VERSION" \
|
||||||
|
-GCP_SERVICE_ACCOUNT_KEY_BASE64="${{ secrets.EI_GCP_SERVICE_ACCOUNT_KEY_BASE64 }}" \
|
||||||
|
-EPHEMERAL_ORG_ID="${{ secrets.EI_EPHEMERAL_ORG_ID }}" || true
|
Reference in New Issue
Block a user