Skip to content

Commit b3ea665

Browse files
committed
Add database logic to prod action
1 parent ba31cd3 commit b3ea665

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/prod.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@ jobs:
2121
- name: Install dependencies
2222
run: pip install --break-system-packages -r requirements.txt
2323

24+
- name: Get Previous Run ID
25+
continue-on-error: true
26+
id: get_id
27+
env:
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
run: |
30+
# Fetches the ID of the last completed run for the current workflow
31+
PREVIOUS_RUN_ID=$(gh run list \
32+
--branch "${{ github.ref_name }}" \
33+
--workflow "${{ github.workflow }}" \
34+
--status success \
35+
--limit 1 \
36+
--json databaseId \
37+
--jq '.[0].databaseId')
38+
echo "previous_run_id=$PREVIOUS_RUN_ID" >> "$GITHUB_OUTPUT"
39+
40+
- name: Download previous database artifact
41+
uses: actions/download-artifact@v8
42+
with:
43+
name: database.json
44+
github-token: ${{ secrets.GITHUB_TOKEN }}
45+
run-id: ${{ steps.get_id.outputs.previous_run_id }}
46+
continue-on-error: true
47+
2448
- name: Call RescueGroups API
2549
env:
2650
CUTEPETSBOSTON_RESCUEGROUPS_API_KEY: ${{ secrets.CUTEPETSBOSTON_RESCUEGROUPS_API_KEY }}
@@ -32,3 +56,10 @@ jobs:
3256
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
3357
APP_ENV: prod
3458
run: python ./main.py
59+
60+
- name: Upload database artifact
61+
uses: actions/upload-artifact@v7
62+
with:
63+
path: database.json
64+
retention-days: 14
65+
archive: false

0 commit comments

Comments
 (0)