Build and Deploy #51
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: Build and Deploy | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 10 * * 1" | |
workflow_dispatch: | |
jobs: | |
run: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.11 | |
cache: pip | |
- name: Install dependencies | |
run: | | |
pip install -e . | |
- name: Run | |
run: | | |
make run | |
env: | |
COVALENT_API_KEY: ${{ secrets.COVALENT_API_KEY }} | |
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }} | |
- name: Export Database and Log File Sizes | |
run: | | |
make tables | |
echo "Files exported:" >> $GITHUB_STEP_SUMMARY | |
{ | |
echo "| Filename | File Size |" | |
echo "| --- | --- |" | |
ls -lh data/tables | tail -n +2 | awk '{printf "| %s | %s |\n", $9, $5}' | |
} >> $GITHUB_STEP_SUMMARY | |
ls -lh data/tables | |
- name: Install Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
- name: Render | |
run: | | |
make render | |
- name: Upload Pages Artifact | |
if: github.event_name == 'push' | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: portal/_site | |
- name: Copy Data Tables and Database | |
run: | | |
cp -r data/tables/ portal/_site/data/ | |
cp -r data/local.duckdb portal/_site/data/database.duckdb | |
- name: Push to IPFS | |
if: github.event_name == 'push' | |
uses: filebase/ipfs-action@master | |
id: ipfs | |
with: | |
path: portal/_site/ | |
service: filebase | |
pinName: gitcoin-grants-data-portal-tables | |
filebaseBucket: gitcoin-grants-data-portal | |
filebaseKey: ${{ secrets.FILEBASE_KEY }} | |
filebaseSecret: ${{ secrets.FILEBASE_SECRET }} | |
key: gitcoin-grants-data-portal-db | |
- name: Update CID file | |
if: github.event_name == 'push' | |
run: echo ${{ steps.ipfs.outputs.cid }} > data/IPFS_CID | |
- name: Commit and Push | |
if: github.event_name == 'push' | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "actions@users.noreply.github.com" | |
git add data/IPFS_CID | |
if git diff-index --quiet HEAD --; then | |
echo "No changes to commit" | |
else | |
git commit -m "chore: :id: Update CID" | |
git push | |
fi | |
deploy: | |
if: github.event_name == 'push' | |
needs: run | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |