Another approach

This commit is contained in:
zandercymatics 2023-11-24 12:44:18 -07:00
parent 9c05dcde44
commit 90282c7cdc
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 19 additions and 23 deletions

View file

@ -7,7 +7,7 @@ on:
inputs:
environment:
type: choice
description: Which environment do you wish load reports for?
description: Which environment load reports for?
options:
- stable
- staging
@ -59,30 +59,28 @@ jobs:
upload-reports:
runs-on: ubuntu-latest
needs: [variables, wait-for-deploy]
env:
CF_USERNAME: CF_{{ needs.variables.outputs.environment }}_USERNAME
CF_PASSWORD: CF_{{ needs.variables.outputs.environment }}_PASSWORD
steps:
- uses: actions/checkout@v3
- name: Install CF CLI
run: |
curl -L "https://packages.cloudfoundry.org/stable?release=linux64-binary&source=github" | tar -zx
sudo mv cf /usr/local/bin
- name: Generate current-federal.csv
run: |
cf api https://api.fr.cloud.gov
cf auth ${{ secrets[env.CF_USERNAME] }} ${{ secrets[env.CF_PASSWORD] }}
cf target -o cisa-dotgov -s ${{ env.ENVIRONMENT }}
cf ssh getgov-${{ env.ENVIRONMENT }} -c "/tmp/lifecycle/shell -c './manage.py generate_current_federal_report'"
env:
ENVIRONMENT: ${{ needs.variables.outputs.environment }}
CF_USERNAME: CF_${{ needs.variables.outputs.environment }}_USERNAME
CF_PASSWORD: CF_${{ needs.variables.outputs.environment }}_PASSWORD
uses: 18f/cg-deploy-action@main
with:
cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-dotgov
cf_space: ${{ needs.variables.outputs.environment }}
full_command: "cf run-task getgov-${{ needs.variables.outputs.environment }} --command 'python manage.py generate_current_federal_report' --name federal"
- name: Generate current-full.csv
run: cf run-task getgov-${{ env.ENVIRONMENT }} "/tmp/lifecycle/shell -c './manage.py generate_current_full_report'"
env:
ENVIRONMENT: ${{ needs.variables.outputs.environment }}
uses: 18f/cg-deploy-action@main
with:
cf_username: ${{ secrets[env.CF_USERNAME] }}
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: cisa-dotgov
cf_space: ${{ needs.variables.outputs.environment }}
full_command: "cf run-task getgov-${{ needs.variables.outputs.environment }} --command 'python manage.py generate_current_full_report' --name full"
comment:
runs-on: ubuntu-latest

View file

@ -3,7 +3,6 @@ import os
from django.apps import apps
from django.views.decorators.http import require_http_methods
from django.http import FileResponse, HttpResponse, JsonResponse
import requests
from login_required import login_not_required
@ -107,7 +106,6 @@ def get_current_federal(request):
file_path = "migrationdata/current-federal.csv"
return serve_file(file_path)
def serve_file(file_path):
"""Downloads a file based on a given filepath. Returns a 404 if not found."""
if os.path.exists(file_path):