Skip to content

Commit

Permalink
Merge pull request #3 from sentrysoftware/Linux-Package-not-found
Browse files Browse the repository at this point in the history
Linux Package not found
  • Loading branch information
MohammedSentry authored Jun 27, 2024
2 parents 4cc7456 + 1e25369 commit 673674c
Showing 1 changed file with 74 additions and 35 deletions.
109 changes: 74 additions & 35 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,64 @@ on:
build_number:
description: 'Enter the build number to compare'
required: true
run_id:
description: 'Enter the GitHub build run ID, example: 9496848962'
required: false

jobs:
sanity-check-ubuntu:
runs-on: ubuntu-latest

steps:
- name: Download artifact from MetricsHub
run: |
shell: bash
env:
# Define variables
OWNER="sentrysoftware"
REPO="metricshub"
BRANCH="main"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: metricshub
BRANCH: main
RUN_ID: ${{ github.event.inputs.run_id }}
run: |
# Debug - Print variables
echo "Owner: $OWNER"
echo "Repo: $REPO"
echo "Branch: $BRANCH"
# Get the latest successful workflow run ID
WORKFLOW_RUNS=$(curl -s -H "Authorization: token ***" "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&status=completed&per_page=5")
RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[] | select(.conclusion == "success") | .id' | head -n 1)
if [ -z "$RUN_ID" ]; then
# Get the latest successful workflow run ID
WORKFLOW_RUNS=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&status=completed&per_page=5")
echo "Workflow runs fetched:"
echo $WORKFLOW_RUNS | jq .
RUN_ID=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[] | select(.conclusion == "success") | .id' | head -n 1)
fi
if [ -z "$RUN_ID" ]; then
echo "No successful run ID found."
exit 1
fi
echo "Latest successful run ID: $RUN_ID"
# 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)
ARTIFACTS=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" $ARTIFACTS_URL)
# Extract artifact information
ARTIFACT_ID=$(echo $ARTIFACTS | jq -r '.artifacts[0].id')
DOWNLOAD_URL="https://api.github.com/repos/$OWNER/$REPO/actions/artifacts/$ARTIFACT_ID/zip"
echo "Artifacts fetched:"
echo $ARTIFACTS | jq .
DOWNLOAD_URL=$(echo $ARTIFACTS | jq -r '.artifacts[] | select(.name | startswith("metricshub-linux")) | .archive_download_url')
if [ -z "$DOWNLOAD_URL" ]; then
echo "No artifact ID found."
exit 1
fi
echo "Artifact download URL: $DOWNLOAD_URL"
# Download the artifact
curl -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o artifact.zip $DOWNLOAD_URL
curl -L -H "Authorization: Bearer $GITHUB_TOKEN" -o artifact.zip $DOWNLOAD_URL
# Unzip the artifact and extract tarball
mkdir -p artifacts
Expand All @@ -56,6 +83,12 @@ jobs:
# Extract tarball (assuming the correct filename is known)
TAR_FILE=$(ls metricshub-linux-*.tar.gz)
if [ -z "$TAR_FILE" ]; then
echo "No tarball found in artifacts."
exit 1
fi
tar -xzf $TAR_FILE
- name: Run MetricsHub and get version
Expand Down Expand Up @@ -97,34 +130,41 @@ jobs:
runs-on: windows-latest

steps:
- name: Checkout this repository
uses: actions/checkout@v4

- name: Download artifacts from MetricsHub
- name: Download artifact from MetricsHub
shell: pwsh
env:
# Define variables
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER: ${{ github.repository_owner }}
REPO: metricshub
BRANCH: main
RUN_ID: ${{ github.event.inputs.run_id }}
run: |
# Define variables
$OWNER = "${{ github.repository_owner }}"
$REPO = "metricshub"
$BRANCH = "main"
# Debug - Print variables
Write-Host "Owner: $OWNER"
Write-Host "Repo: $REPO"
Write-Host "Branch: $BRANCH"
# Get the latest successful workflow run ID
$workflow_runs = Invoke-RestMethod -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri "https://api.github.com/repos/$OWNER/$REPO/actions/runs?branch=$BRANCH&status=completed&per_page=5"
Write-Host "Workflow runs: $($workflow_runs | ConvertTo-Json -Depth 3)"
$run_id = ($workflow_runs.workflow_runs | Where-Object { $_.conclusion -eq "success" })[0].id
Write-Host "Owner: ${env:OWNER}"
Write-Host "Repo: ${env:REPO}"
Write-Host "Branch: ${env:BRANCH}"
if (-not $env:RUN_ID) {
# Get the latest successful workflow run ID
$workflow_runs = Invoke-RestMethod -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri "https://api.github.com/repos/${env:OWNER}/${env:REPO}/actions/runs?branch=${env:BRANCH}&status=completed&per_page=5"
Write-Host "Workflow runs: $($workflow_runs | ConvertTo-Json -Depth 3)"
$run_id = ($workflow_runs.workflow_runs | Where-Object { $_.conclusion -eq "success" })[0].id
} else {
$run_id = $env:RUN_ID
}
if (-not $run_id) {
Write-Error "No successful run ID found."
exit 1
}
# Debug - Print run_id
Write-Host "Run ID: $run_id"
Write-Host "Latest successful run ID: $run_id"
# Get the artifact download URL
$artifacts_url = "https://api.github.com/repos/$OWNER/$REPO/actions/runs/$run_id/artifacts"
$artifacts_url = "https://api.github.com/repos/${env:OWNER}/${env:REPO}/actions/runs/$run_id/artifacts"
$artifacts = Invoke-RestMethod -Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } -Uri $artifacts_url
# Debug - Print artifacts
Expand All @@ -136,8 +176,7 @@ jobs:
Write-Error "No artifact found with name starting with 'metricshub-windows'"
exit 1
}
$artifact_id = $artifact.id
$download_url = "https://api.github.com/repos/$OWNER/$REPO/actions/artifacts/$artifact_id/zip"
$download_url = $artifact.archive_download_url
# Debug - Print download URL
Write-Host "Download URL: $download_url"
Expand Down

0 comments on commit 673674c

Please sign in to comment.