|
| 1 | +name: CKAN Sites Workflow |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run daily at 2 AM UTC |
| 6 | + - cron: '0 2 * * *' |
| 7 | + workflow_dispatch: |
| 8 | + # Allow manual trigger |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths: |
| 13 | + - 'sites-workflow/**' |
| 14 | + - '.github/workflows/sites-workflow.yml' |
| 15 | + |
| 16 | +jobs: |
| 17 | + process-sites: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: '3.9' |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: | |
| 31 | + cd sites-workflow |
| 32 | + pip install -r requirements.txt |
| 33 | + |
| 34 | + - name: Step 1 - Get Sites URLs |
| 35 | + run: | |
| 36 | + cd sites-workflow |
| 37 | + python 1getSitesURL.py |
| 38 | + |
| 39 | + - name: Step 2 - Collect CKAN Statistics |
| 40 | + run: | |
| 41 | + cd sites-workflow |
| 42 | + python 2CKANActionAPI.py |
| 43 | + |
| 44 | + - name: Step 3.1 - Download Existing Dataset |
| 45 | + run: | |
| 46 | + cd sites-workflow |
| 47 | + python 31downloadDataset.py |
| 48 | + |
| 49 | + - name: Step 3.2 - Merge Data |
| 50 | + run: | |
| 51 | + cd sites-workflow |
| 52 | + python 32merger.py |
| 53 | + |
| 54 | + - name: Step 3.3 - Delete Old Resources |
| 55 | + run: | |
| 56 | + cd sites-workflow |
| 57 | + python 33delete.py |
| 58 | + env: |
| 59 | + CKAN_API_KEY: ${{ secrets.CKAN_API_KEY }} |
| 60 | + |
| 61 | + - name: Step 3 - Update Sites Catalog |
| 62 | + run: | |
| 63 | + cd sites-workflow |
| 64 | + python 3updateSitesCatalog.py |
| 65 | + env: |
| 66 | + CKAN_API_KEY: ${{ secrets.CKAN_API_KEY }} |
| 67 | + |
| 68 | + - name: Step 4 - Upload Dataset |
| 69 | + run: | |
| 70 | + cd sites-workflow |
| 71 | + python 4uploadDataset.py |
| 72 | + env: |
| 73 | + CKAN_API_KEY: ${{ secrets.CKAN_API_KEY }} |
| 74 | + |
| 75 | + - name: Archive artifacts |
| 76 | + uses: actions/upload-artifact@v3 |
| 77 | + if: always() |
| 78 | + with: |
| 79 | + name: workflow-outputs |
| 80 | + path: | |
| 81 | + sites-workflow/*.csv |
| 82 | + sites-workflow/*.json |
| 83 | + retention-days: 30 |
| 84 | + |
| 85 | + - name: Notify on failure |
| 86 | + if: failure() |
| 87 | + run: | |
| 88 | + echo "Workflow failed. Check the logs for details." |
| 89 | + # Add notification logic here (email, Slack, etc.) |
0 commit comments