Skip to content

Commit

Permalink
Clean version
Browse files Browse the repository at this point in the history
  • Loading branch information
MohammedSentry committed Jun 5, 2024
1 parent d7c456a commit 2c672cc
Showing 1 changed file with 2 additions and 37 deletions.
39 changes: 2 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,69 +15,34 @@ jobs:

- name: Download artifacts from MetricsHub
run: |
echo "Downloading artifacts from MetricsHub"
# Define variables
OWNER="MohammedSentry"
REPO="metricshub"
BRANCH="main"
# 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
Expand Down

0 comments on commit 2c672cc

Please sign in to comment.