Skip to content

Download test

Download test #31

Workflow file for this run

name: Download Artifacts
on:
push:
branches:
- main
jobs:
download-artifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v2
- name: Download artifacts from another repository
run: |
echo "Downloading artifacts from MetricsHub"
# Define variables
OWNER="MohammedSentry"
REPO="MohammedSentry/metricshub"
RUN_ID=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=main&status=completed&per_page=1" | jq -r '.workflow_runs[0].id')
ARTIFACTS_URL="https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts"
# Get the artifact download URL
ARTIFACTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $ARTIFACTS_URL)
ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[0].id')
DOWNLOAD_URL="https://api.github.com/repos/$OWNER/$REPO/actions/artifacts/$ARTIFACT_ID/zip"
# Download the artifact
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o artifact.zip $DOWNLOAD_URL
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: List downloaded files
run: ls -al artifacts