|
7 | 7 | - cron: '0 6 * * *' # Daily at 6 AM |
8 | 8 |
|
9 | 9 | jobs: |
10 | | - download-latest: |
| 10 | + download-artifact: |
11 | 11 | runs-on: ubuntu-latest |
12 | 12 | steps: |
13 | | - - name: Get latest successful run |
14 | | - id: get-run |
15 | | - uses: actions/github-script@v7 |
16 | | - with: |
17 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
18 | | - script: | |
19 | | - const { data: runs } = await github.rest.actions.listWorkflowRuns({ |
20 | | - owner: 'OPM', |
21 | | - repo: 'ResInsight', |
22 | | - workflow_id: 'ResInsightWithCache.yml', # or workflow filename |
23 | | - status: 'success', |
24 | | - per_page: 1 |
25 | | - }); |
26 | | - |
27 | | - if (runs.total_count === 0) { |
28 | | - core.setFailed('No successful runs found'); |
29 | | - return; |
30 | | - } |
31 | | - |
32 | | - core.setOutput('run-id', runs[0].id); |
33 | | - core.setOutput('run-url', runs[0].html_url); |
| 13 | + - name: Set up authentication |
| 14 | + env: |
| 15 | + GITHUB_TOKEN: ${{ secrets.PAT }} |
| 16 | + run: | |
| 17 | + echo "Authenticated with PAT" |
| 18 | +
|
| 19 | + - name: Get latest successful workflow run |
| 20 | + id: get_run |
| 21 | + run: | |
| 22 | + curl -H "Authorization: token ${{ secrets.PAT }}" \ |
| 23 | + https://api.github.com/repos/OPM/ResInsight/actions/workflows/ResInsightWithCache/runs \ |
| 24 | + | jq '.workflow_runs[] | select(.conclusion=="success") | .id' \ |
| 25 | + | head -n 1 > run_id.txt |
| 26 | + echo "run_id=$(cat run_id.txt)" >> $GITHUB_ENV |
| 27 | +
|
| 28 | + - name: Download artifact |
| 29 | + run: | |
| 30 | + curl -H "Authorization: token ${{ secrets.PAT }}" \ |
| 31 | + -L https://api.github.com/repos/OPM/ResInsight/actions/runs/${{ env.run_id }}/artifacts \ |
| 32 | + -o artifact.zip |
34 | 33 |
|
35 | | - - name: Download artifacts |
36 | | - uses: actions/download-artifact@v4 |
37 | | - with: |
38 | | - name: build-artifacts # Name of the artifact |
39 | | - repository: target-owner/target-repo |
40 | | - run-id: ${{ steps.get-run.outputs.run-id }} |
41 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
42 | | - path: ./downloaded-artifacts |
43 | 34 |
|
44 | 35 | - name: List downloaded files |
45 | 36 | run: | |
46 | 37 | echo "Downloaded files:" |
47 | | - ls -la ./downloaded-artifacts/ |
| 38 | + ls -la . |
0 commit comments