From 00cafdc02a02cd892e376bda35c696813bc1a22f Mon Sep 17 00:00:00 2001 From: Ricky Whitaker Date: Fri, 26 Jan 2024 13:00:17 -0600 Subject: [PATCH] [10.1.x] Updating GHA to match main (#81398) Updating .github/workflows/ephemeral-instances-pr-opened-closed.yml and .github/workflows/pr-commands.yml to match what is in main --- .../ephemeral-instances-pr-opened-closed.yml | 32 ++++++++++++++++--- .github/workflows/pr-commands.yml | 20 +++++++++++- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ephemeral-instances-pr-opened-closed.yml b/.github/workflows/ephemeral-instances-pr-opened-closed.yml index f08aa0d0823..2ca2259396b 100644 --- a/.github/workflows/ephemeral-instances-pr-opened-closed.yml +++ b/.github/workflows/ephemeral-instances-pr-opened-closed.yml @@ -2,11 +2,33 @@ name: 'Ephemeral instances: PR opened/closed' on: pull_request: types: [opened, reopened, closed] -jobs: +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: + needs: config + if: needs.config.outputs.has-secrets runs-on: ubuntu-latest continue-on-error: true - steps: + steps: - name: Setup Go uses: actions/setup-go@v4 with: @@ -20,13 +42,13 @@ jobs: private_key: ${{ secrets.EI_APP_PRIVATE_KEY }} - name: Checkout ephemeral instances repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: grafana/ephemeral-grafana-instances-github-action token: ${{ steps.generate_token.outputs.token }} ref: main path: ephemeral - + - name: Run action env: GITHUB_EVENT: ${{ toJson(github.event)}} @@ -44,4 +66,4 @@ jobs: -REGISTRY="${{ secrets.EI_EPHEMERAL_INSTANCES_REGISTRY }}" \ -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 \ No newline at end of file + -EPHEMERAL_ORG_ID="${{ secrets.EI_EPHEMERAL_ORG_ID }}" || true diff --git a/.github/workflows/pr-commands.yml b/.github/workflows/pr-commands.yml index d868efb6926..51838dc7ae7 100644 --- a/.github/workflows/pr-commands.yml +++ b/.github/workflows/pr-commands.yml @@ -8,11 +8,29 @@ on: concurrency: group: pr-commands-${{ github.event.number }} 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.GRAFANA_PR_AUTOMATION_APP_ID != '' && + secrets.GRAFANA_PR_AUTOMATION_APP_PEM != '' && + secrets.GRAFANA_MISC_STATS_API_KEY != '' + ) || '' }}" ]; then + echo "has-secrets=1" >> "$GITHUB_OUTPUT" + fi + main: + needs: config + if: needs.config.outputs.has-secrets runs-on: ubuntu-latest steps: - name: Checkout Actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: "grafana/grafana-github-actions" path: ./actions