From 2c672cc8a300e46b38d0a3c5998d4ee137730f8d Mon Sep 17 00:00:00 2001 From: Mohammed Kaddouri Date: Wed, 5 Jun 2024 17:20:40 +0200 Subject: [PATCH] Clean version --- .github/workflows/main.yml | 39 ++------------------------------------ 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d44ab39..0a30ade 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,9 +15,6 @@ jobs: - name: Download artifacts from MetricsHub run: | - echo "Downloading artifacts from MetricsHub" - - # Define variables OWNER="MohammedSentry" REPO="metricshub" @@ -25,59 +22,27 @@ jobs: # Get the latest successful workflow run ID WORKFLOW_RUNS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&status=completed&per_page=5") - echo "Workflow runs: $WORKFLOW_RUNS" - RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[] | select(.conclusion == "success") | .id' | head -n 1) - echo "Latest successful workflow run ID: $RUN_ID" - - if [ -z "$RUN_ID" ]; then - echo "No successful workflow runs found for branch: $BRANCH" - exit 1 - fi # Get the artifact download URL ARTIFACTS_URL="https://api.github.com/repos/$OWNER/$REPO/actions/runs/$RUN_ID/artifacts" ARTIFACTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" $ARTIFACTS_URL) - echo "Artifacts JSON: $ARTIFACTS" - - # Check if there are any artifacts - TOTAL_COUNT=$(echo $ARTIFACTS | jq -r '.total_count') - if [ "$TOTAL_COUNT" -eq "0" ]; then - echo "No artifacts found for this run ID: $RUN_ID" - exit 1 - fi # Extract artifact information ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[0].id') - echo "Artifact ID: $ARTIFACT_ID" DOWNLOAD_URL="https://api.github.com/repos/$OWNER/$REPO/actions/artifacts/$ARTIFACT_ID/zip" # Download the artifact - echo "Downloading artifact from $DOWNLOAD_URL" curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o artifact.zip $DOWNLOAD_URL - # Check if the downloaded file is a valid ZIP - if file artifact.zip | grep -q 'Zip archive data'; then - echo "Artifact is a valid ZIP file" - else - echo "Artifact is not a valid ZIP file" - exit 1 - fi - - # Create artifacts directory + # Unzip the artifact and extract tarball mkdir -p artifacts - - # Unzip the artifact unzip artifact.zip -d artifacts cd artifacts tar -xzf metricshub-linux-*.tar.gz - - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: MetricsHub version - run : | + run: | cd artifacts/metricshub/bin ./metricshub --version