You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by dp...@apache.org on 2024/01/23 15:46:54 UTC

(superset) branch master updated: fix: docker ephemeral environment, push only on testenv comment (#26473)

This is an automated email from the ASF dual-hosted git repository.

dpgaspar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 74f953ddd2 fix: docker ephemeral environment, push only on testenv comment (#26473)
74f953ddd2 is described below

commit 74f953ddd26eca42143a6569ae04b1fd86a76002
Author: Daniel Vaz Gaspar <da...@gmail.com>
AuthorDate: Tue Jan 23 15:46:46 2024 +0000

    fix: docker ephemeral environment, push only on testenv comment (#26473)
    
    Co-authored-by: Geido <60...@users.noreply.github.com>
---
 .github/workflows/docker-ephemeral-env.yml | 98 ------------------------------
 .github/workflows/ephemeral-env.yml        | 74 ++++++++++++++++++++++
 2 files changed, 74 insertions(+), 98 deletions(-)

diff --git a/.github/workflows/docker-ephemeral-env.yml b/.github/workflows/docker-ephemeral-env.yml
deleted file mode 100644
index 41f50acb82..0000000000
--- a/.github/workflows/docker-ephemeral-env.yml
+++ /dev/null
@@ -1,98 +0,0 @@
-name: Push ephemeral env image
-
-on:
-  workflow_run:
-    workflows: ["Docker"]
-    types:
-      - completed
-
-jobs:
-  config:
-    runs-on: "ubuntu-latest"
-    if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
-    outputs:
-      has-secrets: ${{ steps.check.outputs.has-secrets }}
-    steps:
-      - name: "Check for secrets"
-        id: check
-        shell: bash
-        run: |
-          if [ -n "${{ (secrets.AWS_ACCESS_KEY_ID != '' &&
-            secrets.AWS_SECRET_ACCESS_KEY != '') || '' }}" ]; then
-            echo "has-secrets=1" >> "$GITHUB_OUTPUT"
-            echo "has secrets!"
-          else
-            echo "has-secrets=0" >> "$GITHUB_OUTPUT"
-            echo "no secrets!"
-          fi
-
-  docker_ephemeral_env:
-    needs: config
-    if: needs.config.outputs.has-secrets
-    name: Push ephemeral env Docker image to ECR
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: "Download artifact"
-        uses: actions/github-script@v3.1.0
-        with:
-          script: |
-            const artifacts = await github.actions.listWorkflowRunArtifacts({
-                owner: context.repo.owner,
-                repo: context.repo.repo,
-                run_id: ${{ github.event.workflow_run.id }},
-            });
-
-            core.info('*** artifacts')
-            core.info(JSON.stringify(artifacts))
-
-            const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
-              return artifact.name == "build"
-            })[0];
-            if(!matchArtifact) return core.setFailed("Build artifacts not found")
-
-            const download = await github.actions.downloadArtifact({
-                owner: context.repo.owner,
-                repo: context.repo.repo,
-                artifact_id: matchArtifact.id,
-                archive_format: 'zip',
-            });
-            var fs = require('fs');
-            fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
-
-      - run: unzip build.zip
-
-      - name: Display downloaded files (debug)
-        run: ls -la
-
-      - name: Get SHA
-        id: get-sha
-        run: echo "::set-output name=sha::$(cat ./SHA)"
-
-      - name: Get PR
-        id: get-pr
-        run: echo "::set-output name=num::$(cat ./PR-NUM)"
-
-      - name: Configure AWS credentials
-        uses: aws-actions/configure-aws-credentials@v1
-        with:
-          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
-          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-          aws-region: us-west-2
-
-      - name: Login to Amazon ECR
-        id: login-ecr
-        uses: aws-actions/amazon-ecr-login@v1
-
-      - name: Load, tag and push image to ECR
-        id: push-image
-        env:
-          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
-          ECR_REPOSITORY: superset-ci
-          SHA: ${{ steps.get-sha.outputs.sha }}
-          IMAGE_TAG: pr-${{ steps.get-pr.outputs.num }}
-        run: |
-          docker load < $SHA.tar.gz
-          docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
-          docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$SHA
-          docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
diff --git a/.github/workflows/ephemeral-env.yml b/.github/workflows/ephemeral-env.yml
index 08e3a998c3..2e8178199f 100644
--- a/.github/workflows/ephemeral-env.yml
+++ b/.github/workflows/ephemeral-env.yml
@@ -79,6 +79,80 @@ jobs:
           })
           core.setFailed(errMsg)
 
+  docker_ephemeral_env:
+    needs: config
+    if: needs.config.outputs.has-secrets
+    name: Push ephemeral env Docker image to ECR
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: "Download artifact"
+        uses: actions/github-script@v3.1.0
+        with:
+          script: |
+            const artifacts = await github.actions.listWorkflowRunArtifacts({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                run_id: ${{ github.event.workflow_run.id }},
+            });
+
+            core.info('*** artifacts')
+            core.info(JSON.stringify(artifacts))
+
+            const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
+              return artifact.name === "build";
+            });
+
+            if (!matchArtifact.length) {
+              return core.setFailed("Build artifacts not found");
+            }
+
+            const download = await github.actions.downloadArtifact({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                artifact_id: matchArtifact[0].id,
+                archive_format: 'zip',
+            });
+            var fs = require('fs');
+            fs.writeFileSync('${{github.workspace}}/build.zip', Buffer.from(download.data));
+
+      - run: unzip build.zip
+
+      - name: Display downloaded files (debug)
+        run: ls -la
+
+      - name: Get SHA
+        id: get-sha
+        run: echo "::set-output name=sha::$(cat ./SHA)"
+
+      - name: Get PR
+        id: get-pr
+        run: echo "::set-output name=num::$(cat ./PR-NUM)"
+
+      - name: Configure AWS credentials
+        uses: aws-actions/configure-aws-credentials@v1
+        with:
+          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
+          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
+          aws-region: us-west-2
+
+      - name: Login to Amazon ECR
+        id: login-ecr
+        uses: aws-actions/amazon-ecr-login@v1
+
+      - name: Load, tag and push image to ECR
+        id: push-image
+        env:
+          ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
+          ECR_REPOSITORY: superset-ci
+          SHA: ${{ steps.get-sha.outputs.sha }}
+          IMAGE_TAG: pr-${{ steps.get-pr.outputs.num }}
+        run: |
+          docker load < $SHA.tar.gz
+          docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
+          docker tag $SHA $ECR_REGISTRY/$ECR_REPOSITORY:$SHA
+          docker push -a $ECR_REGISTRY/$ECR_REPOSITORY
+
   ephemeral_env_up:
     needs: ephemeral_env_comment
     if: needs.ephemeral_env_comment.outputs.slash-command == 'up'