|
| 1 | +name: "Run script to update the D4D Synapse table" |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - 'src/html/output/*' |
| 10 | + |
| 11 | +env: |
| 12 | + IGNORE_UNCHANGED: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + update_d4d_table: |
| 16 | + name: Run script to update synapse tables with data changes |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + matrix: |
| 20 | + python-version: [3.10.x] |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python ${{ matrix.python-version }} |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: ${{ matrix.python-version }} |
| 28 | + |
| 29 | + - name: Install Poetry |
| 30 | + |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + poetry install --no-interaction |
| 35 | +
|
| 36 | + - name: Install jq |
| 37 | + run: sudo apt-get install jq |
| 38 | + |
| 39 | + - name: Get changed files |
| 40 | + id: changes |
| 41 | + run: | |
| 42 | + CHANGED_FILES=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 43 | + https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} | jq -r '.files[].filename?' | grep -e 'src/html/output/.*\.css$' -e 'src/html/output/.*\.html$') |
| 44 | + CHANGED_FILES=$(echo "$CHANGED_FILES" | tr '\n' ' ') |
| 45 | + echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV |
| 46 | + echo "Files changed: $CHANGED_FILES" |
| 47 | + continue-on-error: true |
| 48 | + |
| 49 | + - name: Run script to update synapse tables |
| 50 | + run: | |
| 51 | + if [ -n "${{ env.CHANGED_FILES }}" ]; then |
| 52 | + poetry run python utils/d4d_to_synapse_table.py |
| 53 | + elif ${{ env.IGNORE_UNCHANGED }}; then |
| 54 | + poetry run python utils/d4d_to_synapse_table.py |
| 55 | + else |
| 56 | + echo "No updated files found. Exiting." |
| 57 | + fi |
| 58 | + env: |
| 59 | + SYNAPSE_AUTH_TOKEN: ${{ secrets.SYNAPSE_AUTH_TOKEN }} |
0 commit comments