Fetch Contribution Data 🛠️ #33
This file contains hidden or 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: Fetch Contribution Data 🛠️ | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
schedule: | |
- cron: "0 0 * * 1" # Runs at 00:00 UTC on Monday | |
jobs: | |
container-job: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: pyramation/postgis | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "22" | |
- name: Install dependencies | |
run: yarn install | |
- name: Install PostgreSQL client tools | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y postgresql-client | |
- name: Wait for PostgreSQL to be ready | |
run: | | |
echo "Waiting for PostgreSQL to be ready..." | |
for i in {1..30}; do | |
pg_isready -h localhost -p 5432 -U postgres && break | |
sleep 1 | |
done | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_FE_DEPLOYER_ACCESS }} | |
aws-secret-access-key: ${{ secrets.AWS_FE_DEPLOYER_SECRET }} | |
aws-region: "us-east-1" | |
- name: Install AWS CLI v2 | |
run: | | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o /tmp/awscliv2.zip | |
unzip -q /tmp/awscliv2.zip -d /tmp | |
rm /tmp/awscliv2.zip | |
sudo /tmp/aws/install --update | |
rm -rf /tmp/aws/ | |
- name: Run it 🚀 | |
run: | | |
echo "Building project..." | |
yarn build | |
echo "Setting up database schemas..." | |
cd ./packages/stats-db | |
./scripts/schema.sh -s npm | |
./scripts/schema.sh -s github | |
echo "Fetching NPM data..." | |
yarn npm:fetch:packages | |
yarn npm:fetch:downloads | |
yarn npm:report | |
yarn npm:badges | |
yarn npm:readme | |
echo "Fetching GitHub data..." | |
yarn gh:fetch | |
echo "Uploading database dump to S3..." | |
yarn db:dump:s3 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DATABASE_URL: postgres://postgres:password@localhost:5432/example_db | |
# AWS S3 Configuration | |
AWS_REGION: us-east-1 | |
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }} | |
# AWS Credentials | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_FE_DEPLOYER_ACCESS }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_FE_DEPLOYER_SECRET }} | |
- name: Upload artifacts 📦 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: lib-count-badges | |
path: | | |
output/badges/lib-count/total_downloads.json | |
output/badges/lib-count/monthly_downloads.json | |
output/badges/lib-count/utils_category.json | |
output/badges/lib-count/launchql_category.json | |
output/badges/lib-count/hyperweb_category.json |