Quay Statistics Update #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Quay Statistics Update | |
on: | |
schedule: | |
# weekly cron job | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
quay-query: | |
runs-on: ubuntu-22.04 | |
env: | |
SHELL: /bin/bash | |
REPO_NAME_LEGACY: cnf-certification-test | |
REPO_NAME_CURRENT: certsuite | |
NS_NAME_LEGACY: testnetworkfunction | |
NS_NAME_CURRENT: redhat-best-practices-for-k8s | |
steps: | |
- name: Install the JQ package | |
run: sudo apt-get install jq -y | |
- name: Clone the telco-bot repository | |
uses: actions/checkout@v4 | |
# Clone the go-quay repository | |
- name: Checkout go-quay | |
uses: actions/checkout@v4 | |
with: | |
repository: 'sebrandon1/go-quay' | |
path: go-quay | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
- name: Build the go-quay project | |
run: go build | |
working-directory: go-quay | |
- name: Run the go-quay project to gather the last 7 days of Quay statistics | |
run: | | |
TODAY=$(date +%m/%d/%Y) | |
SEVEN_DAYS_AGO=$(date --date "7 days ago" +%m/%d/%Y) | |
echo "Querying the Quay statistics for the last 7 days" | |
echo "Today: ${TODAY}" | |
echo "7 days ago: ${SEVEN_DAYS_AGO}" | |
echo "---------------------------------" | |
echo "Querying the legacy repository: ${NS_NAME_LEGACY}/${REPO_NAME_LEGACY}" | |
RESULT=$(./go-quay get aggregatedlogs -t ${{ secrets.QUAY_TOKEN_LEGACY }} -n ${NS_NAME_LEGACY} -r ${REPO_NAME_LEGACY} -s ${SEVEN_DAYS_AGO} -e ${TODAY}) | |
echo "Result of the legacy repository query: ${RESULT}" | |
echo $RESULT > ${GITHUB_WORKSPACE}/quay-output-legacy.json | |
echo "Querying the current repository: ${NS_NAME_CURRENT}/${REPO_NAME_CURRENT}" | |
RESULT=$(./go-quay get aggregatedlogs -t ${{ secrets.QUAY_TOKEN }} -n ${NS_NAME_CURRENT} -r ${REPO_NAME} -s ${SEVEN_DAYS_AGO} -e ${TODAY}) | |
echo "Result of the current repository query: ${RESULT}" | |
echo $RESULT > ${GITHUB_WORKSPACE}/quay-output.json | |
working-directory: go-quay | |
- name: Print the Quay statistics | |
run: | | |
cat ${GITHUB_WORKSPACE}/quay-output-legacy.json | |
cat ${GITHUB_WORKSPACE}/quay-output.json | |
- name: Fail if the Quay statistics are empty | |
run: | | |
if [ ! -s ${GITHUB_WORKSPACE}/quay-output-legacy.json ]; then | |
echo "The Quay statistics for the legacy repository are empty" | |
exit 1 | |
fi | |
if [ ! -s ${GITHUB_WORKSPACE}/quay-output.json ]; then | |
echo "The Quay statistics for the current repository are empty" | |
exit 1 | |
fi | |
- name: Send the message to Slack | |
run: | | |
TODAY=$(date +%m/%d/%Y) | |
SEVEN_DAYS_AGO=$(date --date "7 days ago" +%m/%d/%Y) | |
# Build the names of the namespace/repo | |
CURRENT_REPO_NAME=${NS_NAME_CURRENT}/${REPO_NAME_CURRENT} | |
LEGACY_REPO_NAME=${NS_NAME_LEGACY}/${REPO_NAME_LEGACY} | |
./scripts/quay-stats-msg.sh ${{ secrets.QUAY_QUERY_SLACK_URL }} ${GITHUB_WORKSPACE}/quay-output-legacy.json ${GITHUB_WORKSPACE}/quay-output.json ${SEVEN_DAYS_AGO} ${TODAY} ${LEGACY_REPO_NAME} ${CURRENT_REPO_NAME} |