fix(infra) - Fix how we download and upload repo names (#11613)

Co-authored-by: gemini-cli-robot <gemini-cli-robot@google.com>
This commit is contained in:
shishu314
2025-10-21 16:33:54 -04:00
committed by GitHub
parent dd3b1cb653
commit f5e07d94bd
2 changed files with 21 additions and 37 deletions

View File

@@ -35,37 +35,27 @@ jobs:
outputs: outputs:
repo_name: '${{ steps.output-repo-name.outputs.repo_name }}' repo_name: '${{ steps.output-repo-name.outputs.repo_name }}'
steps: steps:
- name: 'Download artifact' - name: 'Mock Repo Artifact'
if: "${{ github.event_name == 'workflow_run' }}" if: "${{ github.event_name != 'workflow_run' }}"
uses: 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd' # ratchet:actions/github-script@v8 env:
REPO_NAME: '${{ github.event.inputs.repo_name }}'
run: |
mkdir -p ./pr
echo '${{ env.REPO_NAME }}' > ./pr/repo_name
- uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
with: with:
script: | name: 'repo_name'
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ path: 'pr/'
owner: context.repo.owner, - name: 'Download the repo_name artifact'
repo: context.repo.repo, uses: 'actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0' # ratchet:actions/download-artifact@v5
run_id: context.payload.workflow_run.id, env:
}); RUN_ID: "${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}"
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { with:
return artifact.name == "repo_name" github-token: '${{ secrets.GITHUB_TOKEN }}'
})[0]; name: 'repo_name'
let download = await github.rest.actions.downloadArtifact({ run-id: '${{ env.RUN_ID }}'
owner: context.repo.owner, path: '${{ runner.temp }}/artifacts'
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const temp = '${{ runner.temp }}/artifacts';
if (!fs.existsSync(temp)){
fs.mkdirSync(temp);
}
fs.writeFileSync(path.join(temp, 'repo_name.zip'), Buffer.from(download.data));
- name: 'Unzip artifact'
if: "${{ github.event_name == 'workflow_run' }}"
run: 'unzip "${{ runner.temp }}/artifacts/repo_name.zip" -d "${{ runner.temp }}/artifacts"'
- name: 'Output Repo Name' - name: 'Output Repo Name'
if: "${{ github.event_name == 'workflow_run' }}"
id: 'output-repo-name' id: 'output-repo-name'
uses: 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd' # ratchet:actions/github-script@v8 uses: 'actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd' # ratchet:actions/github-script@v8
with: with:
@@ -74,14 +64,8 @@ jobs:
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const temp = '${{ runner.temp }}/artifacts'; const temp = '${{ runner.temp }}/artifacts';
const repo_name = Number(fs.readFileSync(path.join(temp, 'repo_name'))); const repo_name = String(fs.readFileSync(path.join(temp, 'repo_name')));
core.setOutput('repo_name', repo_name); core.setOutput('repo_name', repo_name);
- name: 'Output Input Repo Name'
if: "${{ github.event_name != 'workflow_run' }}"
id: 'output-input-repo-name'
run: |
echo "repo_name=${{ github.event.inputs.repo_name }}" >> "$GITHUB_OUTPUT"
shell: 'bash'
e2e_linux: e2e_linux:
name: 'E2E Test (Linux) - ${{ matrix.sandbox }}' name: 'E2E Test (Linux) - ${{ matrix.sandbox }}'

View File

@@ -19,7 +19,7 @@ jobs:
REPO_NAME: '${{ github.event.repository.name }}' REPO_NAME: '${{ github.event.repository.name }}'
run: | run: |
mkdir -p ./pr mkdir -p ./pr
echo '$REPO_NAME' > ./pr/repo_name echo '${{ env.REPO_NAME }}' > ./pr/repo_name
- uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4 - uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
with: with:
name: 'repo_name' name: 'repo_name'