mirror of https://github.com/apache/superset.git
fix(ci): ephemeral env build (#26852)
This commit is contained in:
parent
5172e252a1
commit
807c57c531
|
@ -66,7 +66,6 @@ github:
|
|||
- cypress-matrix (1, chrome)
|
||||
- cypress-matrix (2, chrome)
|
||||
- cypress-matrix (3, chrome)
|
||||
- docker-build
|
||||
- frontend-build
|
||||
- pre-commit (3.9)
|
||||
- python-lint (3.9)
|
||||
|
|
|
@ -47,38 +47,3 @@ jobs:
|
|||
run: |
|
||||
pip install click
|
||||
./scripts/build_docker.py ${{ matrix.build_preset }} ${{ github.event_name }} --platform ${{ matrix.platform }}
|
||||
|
||||
|
||||
ephemeral-docker-build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build ephemeral env image
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
|
||||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
run: |
|
||||
pip install click
|
||||
./scripts/build_docker.py "ci" "pull_request" --platform linux/amd64
|
||||
mkdir -p ./build
|
||||
echo ${{ github.sha }} > ./build/SHA
|
||||
echo ${{ github.event.pull_request.number }} > ./build/PR-NUM
|
||||
docker save ${{ github.sha }}-ci | gzip > ./build/${{ github.sha }}.tar.gz
|
||||
|
||||
- name: Upload build artifacts
|
||||
if: github.event_name == 'pull_request'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build
|
||||
path: build/
|
||||
|
|
|
@ -79,55 +79,51 @@ jobs:
|
|||
})
|
||||
core.setFailed(errMsg)
|
||||
|
||||
docker_ephemeral_env:
|
||||
needs: config
|
||||
if: needs.config.outputs.has-secrets
|
||||
name: Push ephemeral env Docker image to ECR
|
||||
ephemeral-docker-build:
|
||||
needs: ephemeral_env_comment
|
||||
name: docker-build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: "Download artifact"
|
||||
uses: actions/github-script@v3.1.0
|
||||
- name: Get Info from comment
|
||||
uses: actions/github-script@v3
|
||||
id: get-pr-info
|
||||
with:
|
||||
script: |
|
||||
const artifacts = await github.actions.listWorkflowRunArtifacts({
|
||||
const request = {
|
||||
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");
|
||||
pull_number: ${{ github.event.issue.number }},
|
||||
}
|
||||
core.info(`Getting PR #${request.pull_number} from ${request.owner}/${request.repo}`)
|
||||
const pr = await github.pulls.get(request);
|
||||
return pr.data;
|
||||
|
||||
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
|
||||
- name: Debug
|
||||
id: get-sha
|
||||
run: echo "::set-output name=sha::$(cat ./SHA)"
|
||||
run: |
|
||||
echo "sha=${{ fromJSON(steps.get-pr-info.outputs.result).head.sha }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Get PR
|
||||
id: get-pr
|
||||
run: echo "::set-output name=num::$(cat ./PR-NUM)"
|
||||
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} : ${{steps.get-sha.outputs.sha}} )"
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ steps.get-sha.outputs.sha }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Build ephemeral env image
|
||||
run: |
|
||||
docker buildx build --target ci \
|
||||
--load \
|
||||
-t ${{ steps.get-sha.outputs.sha }} \
|
||||
-t "pr-${{ github.event.issue.number }}" \
|
||||
--platform linux/amd64 \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
.
|
||||
|
||||
- name: Configure AWS credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
|
@ -146,9 +142,8 @@ jobs:
|
|||
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 }}
|
||||
IMAGE_TAG: pr-${{ github.event.issue.number }}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue