fix: ephemeral envs fail on noop (#31236)

This commit is contained in:
Daniel Vaz Gaspar 2024-12-09 20:06:45 +00:00 committed by GitHub
parent 73d21a87ae
commit 654701af4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 6 deletions

View File

@ -35,22 +35,26 @@ jobs:
- name: Eval comment body for /testenv slash command - name: Eval comment body for /testenv slash command
uses: actions/github-script@v7 uses: actions/github-script@v7
env:
COMMENT_BODY: ${{ github.event.inputs.comment_body || github.event.comment.body }}
id: eval-body id: eval-body
with: with:
result-encoding: string result-encoding: string
script: | script: |
const pattern = /^\/testenv (up|down)/; const pattern = /^\/testenv (up|down)/;
const result = pattern.exec('${{ github.event.inputs.comment_body || github.event.comment.body }}'); const result = pattern.exec(process.env.COMMENT_BODY || '');
return result === null ? 'noop' : result[1]; return result === null ? 'noop' : result[1];
- name: Looking for feature flags - name: Looking for feature flags
uses: actions/github-script@v7 uses: actions/github-script@v7
env:
COMMENT_BODY: ${{ github.event.inputs.comment_body || github.event.comment.body }}
id: eval-feature-flags id: eval-feature-flags
with: with:
script: | script: |
const pattern = /FEATURE_(\w+)=(\w+)/g; const pattern = /FEATURE_(\w+)=(\w+)/g;
let results = []; let results = [];
[...'${{ github.event.inputs.comment_body || github.event.comment.body }}'.matchAll(pattern)].forEach(match => { [...process.env.COMMENT_BODY.matchAll(pattern)].forEach(match => {
const config = { const config = {
name: `SUPERSET_FEATURE_${match[1]}`, name: `SUPERSET_FEATURE_${match[1]}`,
value: match[2], value: match[2],
@ -88,9 +92,7 @@ jobs:
const action = '${{ steps.eval-body.outputs.result }}'; const action = '${{ steps.eval-body.outputs.result }}';
const runId = context.runId; const runId = context.runId;
const workflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; const workflowUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`;
const body = action === 'noop' const body = `@${user} Processing your ephemeral environment request [here](${workflowUrl}).`;
? `@${user} No ephemeral environment action detected. Please use '/testenv up' or '/testenv down'. [View workflow run](${workflowUrl}).`
: `@${user} Processing your ephemeral environment request [here](${workflowUrl}).`;
if (action !== 'noop') { if (action !== 'noop') {
await github.rest.issues.createComment({ await github.rest.issues.createComment({
owner: context.repo.owner, owner: context.repo.owner,
@ -99,13 +101,16 @@ jobs:
body, body,
}); });
} }
else {
core.setFailed('No ephemeral environment action detected.');
}
ephemeral-docker-build: ephemeral-docker-build:
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.issue_number || github.event.issue.number || github.run_id }}-build group: ${{ github.workflow }}-${{ github.event.inputs.issue_number || github.event.issue.number || github.run_id }}-build
cancel-in-progress: true cancel-in-progress: true
needs: ephemeral-env-comment needs: ephemeral-env-comment
if: needs.ephemeral-env-comment.outputs.slash-command == 'up'
name: ephemeral-docker-build name: ephemeral-docker-build
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps: