name: Test


on:
  workflow_run:
    workflows: ["Foo"]
    types:
      - completed

jobs:
  docker:
    runs-on: ubuntu-latest
    if: >
      github.event.workflow_run.event == 'pull_request' &&
      github.event.workflow_run.conclusion == 'success'
    outputs:
      version-json: ${{ steps.show_versions.outputs.version-json }}
    steps:
      - name: 'Download artifact'
        uses: actions/github-script@v3.1.0
        with:
          script: |
            var artifacts = await github.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: ${{ github.event.workflow_run.id }},
            });
            var matchArtifactNacos = artifacts.data.artifacts.filter((artifact) => {
               return artifact.name == "nacos"
            })[0];
            var download = await github.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifactNacos.id,
               archive_format: 'zip',
            });
            var fs = require('fs');
            fs.writeFileSync('${{github.workspace}}/nacos.zip', Buffer.from(download.data));
      - run: |
          unzip nacos.zip
          mkdir nacos
          cp -r nacos-* nacos/
      - name: save docker_2 images
        run: |
          mv ./build_backup/* nacos-e2e/cicd/build/
